#include /** * @title 128bit整数型 * @docs int128.md */ #ifdef __SIZEOF_INT128__ using uint128_t = __uint128_t; using int128_t = __int128_t; #else #include using uint128_t = boost::multiprecision::uint128_t; using int128_t = boost::multiprecision::int128_t; #endif int main(){ int64_t N, K, X, Y; while(std::cin >> N >> K >> X >> Y){ std::vector A(N); for(int i = 0; i < N; ++i) std::cin >> A[i]; std::sort(A.begin(), A.end()); for(int i = 0; i < N; ++i){ A[i] -= 1; A[i] = (A[i] + K - 1) / K; } int64_t ans = 0; int64_t t = 0; for(int i = 0; i < N; ++i){ ans += (int64_t)std::min((int128_t)(A[i] - t) * (N - i) * X, (int128_t)(A[i] - t) * Y); t = A[i]; } std::cout << ans << "\n"; } return 0; }