#include #include #include #include using namespace std; using ll = long long; template using grid = vector>; #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--) #define input(...) __VA_ARGS__; in(__VA_ARGS__) void print() { std::cout << std::endl; } template void print(Head&& head, Tail&&... tail) { std::cout << head << " "; print(std::forward(tail)...); } void in() { } template void in(Head&& head, Tail&&... tail) { cin >> head; in(std::forward(tail)...); } int main() { ll input(n, k, x, y); vector a(n); REP(i, n) cin >> a[i]; REP(i, n) a[i]--; sort(a.begin(), a.end()); ll woundeds = n; while (woundeds * x >= y) woundeds -= 1; ll all; if (woundeds == n) all = 0; else all = (a[n - woundeds - 1] + k - 1) / k; ll ans = all * y; REP(i, woundeds) { ans += (((a[n - woundeds + i] - all * k) + k - 1) / k) * x; } print(ans); }