#include using namespace std; int INF = 1000000001; long long f(vector &A, long long X, long long Y, long long v){ int N = A.size(); long long ans = v * Y; for (int i = 0; i < N; i++){ if (A[i] > v){ ans += (A[i] - v) * X; } } return ans; } int main(){ long long N, K, X, Y; cin >> N >> K >> X >> Y; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; A[i] -= 1; A[i] = (A[i] + K - 1) / K; } sort(A.begin(), A.end()); Y = min(Y, N * X); long long left = -1; long long right = INF; while (right - left > 2){ long long mid1 = (left * 2 + right) / 3; long long mid2 = (left + right * 2) / 3; if (f(A, X, Y, mid1) > f(A, X, Y, mid2)){ left = mid1; } else { right = mid2; } } long long a = f(A, X, Y, left); long long b = f(A, X, Y, left + 1); long long c = f(A, X, Y, left + 2); cout << min({a, b, c}) << endl; }