#include using namespace std; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>n>>k>>x>>y; vector as(n); for(Int i=0;i>as[i]; vector bs(n); for(Int i=0;i__int128_t { __int128_t res=t*y; for(Int b:bs) if(b>t) res+=(b-t)*x; chmin(ans,res); return res; }; Int L=0,R=1e9; calc(L); calc(R); while(L+100>1; Int M2=M1+1; if(calc(M1)>calc(M2)) L=M1; else R=M2; } for(Int t=L-100;t