#include #include #include #include using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint32_t N, K, X, Y, i; cin >> N >> K >> X >> Y; vector A(N); for (i = 0; i != N; ++i) cin >> A[i]; sort(A.begin(), A.end()); uint32_t HP = 1; uint64_t ans = 0; for (i = 0; i != N; ++i) { if (HP >= A[i]) continue; if (X * static_cast(N - i) < Y) ans += (A[i] - HP + K - 1) / K * (X * static_cast(N - i)); else ans += (A[i] - HP + K - 1) / K * static_cast(Y); HP += (A[i] - HP + K - 1) / K * K; } cout << ans << '\n'; return 0; }