#include #include #include #include #include #include #include using namespace std; typedef long long int ll; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll n,k,x,y; cin >> n >> k >> x >> y; vector a(n); for(int i=0;i> a[i]; a[i]--; a[i]=(a[i]+k-1)/k; } ll res=0; sort(a.begin(), a.end()); ll cnt=0; for(int i=0;iy){ res+=(a[i]-cnt)*y; cnt=a[i]; } else{ res+=(a[i]-cnt)*x; } } cout << res << endl; }