#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = false; //---------------------------------// int main() { int N, K, X, Y; cin >> N >> K >> X >> Y; vector A(N); REP(i, N) { scanf("%d", &A[i]); A[i] = (A[i] - 1 + K - 1) / K; } sort(ALL(A)); vector sum(N + 1); REP(i, N) sum[i + 1] += sum[i] + A[i]; ll ans = sum[N] <= longINF / X ? sum[N] * X : longINF; REP(i, N) { // 人 i まで全体魔法 ll cur = (ll)A[i] * Y; // 残り s 回個別魔法 ll s = (sum[N] - sum[i + 1]) - (ll)(N - i - 1) * A[i]; if (s <= longINF / X) chmin(ans, cur + s * X); } cout << ans << endl; }