#include #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--) #define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++) #define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++) #define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++) #define ALL(x) x.begin(), x.end() using ll = long long; using namespace std; int main(){ int n, k, x, y; cin >> n >> k >> x >> y; vector a(n); map c; ll csum = 0; rep(i, n){ int in; cin >> in; in--; a.at(i) = in; c[(in+k-1)/k]++; csum += (ll)(in+k-1)/k; } ll ans = 1e18+5e17; ll ux = 0, xc = 0; bool f = false; rrepit(ritr, c){ ll add = (ll)ritr->first * y; add += (ll)ux * x; if(ans > add){ ans = add; }else{ f = true; break; } // cerr << ritr->first << " " << ritr->second << " " << ux << " " << add << endl; if(ritr != c.rend()){ auto itr = ritr; itr++; ll diff = ritr->first - itr->first; ux += diff*(ritr->second); ux += diff*xc; xc += ritr->second; } } if(f == false){ ll add = (ll)x * csum; ans = min(ans, add); } cout << ans << endl; return 0; }