#include #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++) using namespace std; templateinline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;} templateinline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;} typedef long long ll; // yukicoder No.1071 ベホマラー // 2020.06.06 // Kの商の繰り上げ、昇順に並び替え、右側から累積和、O(N) int main(){ ios::sync_with_stdio(false); cin.tie(0); ll N, K, X, Y; cin >> N >> K >> X >> Y; vector A(N); REPLL(i, N){ cin >> A[i]; A[i]--; A[i] = (A[i]+(K-1))/K; } sort(A.begin(), A.end()); vector AA(N); for(ll i = N-1; i >= 0; i--){ if(i == N-1){ AA[i] = A[i]; }else{ AA[i] = AA[i+1]+A[i]; } } ll ans = 1e18; ans = min(ans, A[N-1]*Y); REPLL(i, N){ if(i == 0){ ans = min(ans, AA[i]*X); }else{ ans = min(ans, A[i-1]*Y + (AA[i]-A[i-1]*(N-i))*X); } } cout << ans << endl; }