#include using namespace std; #define ll long long #define vi vector #define vvi vector> #define all(a) (a).begin(), (a).end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) const int MOD = 1e9+7; const ll LINF = 1e18; const int INF = 1e9; ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z; string S, T; int main() { cin >> N >> K >> X >> Y; vi arr(N); vi brr; for (int i = 0; i < N; i++) {cin >> A;arr.at(i) =A-1;} rep(i,N) { if(arr[i] > 0) { brr.push_back(arr[i]); } } while(!brr.empty()) { B = brr.size(); vi crr; C += min(B*X,Y); rep(i,B) { brr[i] -= K; if(brr[i] > 0) crr.push_back(brr[i]); } brr = crr; crr.clear(); } cout << C; return 0; }