/** * @FileName a.cpp * @Author kanpurin * @Created 2020.06.05 21:46:51 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { ll n, k, x, y; cin >> n >> k >> x >> y; vector< ll > a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } ll p = (y + x - 1) / x; ll ans = 0; sort(a.begin(), a.end()); if (p <= 1) { cout << (a[n - 1] - 1 + k - 1) / k * y << endl; return 0; } if (p >= n) { for (int i = 0; i < n; i++) { ans += (a[i] - 1 + k - 1) / k * x; } cout << ans << endl; return 0; } int q = (a[n - p] - 1 + k - 1) / k; ans = (a[n - p] - 1 + k - 1) / k * y; for (int i = p; i < n; i++) { ans += (a[i] - 1 - q * k + k - 1) / k * x; } cout << ans << endl; return 0; }