#include using namespace std; typedef long long ll; typedef long double ld; #define rep(i,n) for (int i = 0; i < (n); ++i) templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> n >> k >> x >> y; vector a(n),c(n); rep(i,n){ cin >> a[i]; c[i]=(a[i]-1+k-1)/k; } sort(c.begin(),c.end()); ll now=0,ans=0; rep(i,n){ if((n-i)*x>=y){ ans+=y*(c[i]-now); now=c[i]; } else{ ans+=(n-i)*x*(c[i]-now); now=c[i]; } } cout << ans << endl; }