#include #define rep(i,n) for (int i = 0; i < (n); i ++) using namespace std; using ll = long long; using PL = pair; using P = pair; constexpr int INF = 1000000000; constexpr long long HINF = 1000000000000000; constexpr long long MOD = 1000000007; constexpr double EPS = 1e-4; constexpr double PI = 3.14159265358979; int main() { ll N,K,X,Y; cin >> N >> K >> X >> Y; vector A(N); rep(i,N) { cin >> A[i]; A[i] --; } sort(A.begin(),A.end()); int people = Y/X; ll ans = 0; if (people == 0) { ans = (A[N - 1] + K - 1)/K * Y; cout << ans << endl; return 0; } if (people >= N) { rep(i,N) ans += (A[i] + K - 1)/K * X; cout << ans << endl; return 0; } ll damage = (A[N - people - 1] + K - 1)/K * K; ans = (A[N - people - 1] + K - 1)/K * Y; for (int i = N - people;i < N;i ++) { if (A[i] - damage > 0) { ans += (A[i] - damage + K - 1)/K * X; } } cout << ans << endl; return 0; }