#include #include #include #include #include #include #include #include #include #include #include #include #define vll vector #define vvvl vector #define vvl vector> #define VV(a, b, c, d) vector>(a, vector(b, c)) #define VVV(a, b, c, d) vector(a, vvl(b, vll (c, d))); #define re(c, b) for(ll c=0;c> n >> k >> x >> y; ll al = 1; multiset st; re(i, n){ ll t;std::cin >> t; if(t!=1) st.insert(t); } ll ans = 0; while(!st.empty()){ while(!st.empty()&&(*st.begin())<=al) st.erase(st.begin()); if(st.empty()) break; ll z = st.size(); ll top = *st.begin() - al; ll tm = top/k + (top%k?1:0); if(z*x>=y){ ans += y * tm; al += k * tm; }else{ ans += x * tm; st.erase(st.begin()); } } std::cout << ans << '\n'; }