#include #include #include #include using namespace std; long long n,a,b,x,y; vector R; bool solve(long long ce){ int nwa = a; priority_queue> A; for(int i = 0; n > i; i++){ if(R[i]-ce > 0){ A.push(R[i]-ce); } } while(nwa){ if(A.size() == 0){ return true; } auto z = A.top();A.pop(); if(z > x){ A.push(z-x); } nwa--; } long long size = 0; while(A.size()){ auto z = A.top();A.pop(); size+=z; } if(size > b*y){ if(ce == 6)cout << size << " " << b*y << endl; return false; }else{ return true; } } int main(){ cin>>n>>a>>b>>x>>y; for(int i = 0; n > i; i++){ int t;cin>>t; R.push_back(t); } long long mn = 0; long long mx = 1000000000; while(abs(mn-mx) > 1){ long long ce = (mn+mx)/2; if(solve(ce)){ mx = ce; }else{ mn = ce; } } cout << mx << endl; }