#include #define _overload(_1,_2,_3,name,...) name #define _rep(i,n) _range(i,0,n) #define _range(i,a,b) for(int i=int(a);i=int(b);--i) #define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__) #define _all(arg) begin(arg),end(arg) #define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg)) #define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary) #define clr(a,b) memset((a),(b),sizeof(a)) #define bit(n) (1LL<<(n)) #define popcount(n) (__builtin_popcountll(n)) templatebool chmax(T &a, const T &b) { return (abool chmin(T &a, const T &b) { return (b deq; inline bool check(int i,int j,int k){ return (ca[j]-ca[i])*(cb[k]-cb[j])>= (cb[j]-cb[i])*(ca[k]-ca[j]);} inline ll f(int idx,int i){ return -ca[idx]*i+cb[idx];} int main(void){ int n,a,b,w; cin >> n >> a >> b >> w; rep(i,n) cin >> d[i]; dp[0]=w,ca[0]=0,cb[0]=dp[0]; deq.push_back(0); rep(i,1,n+1){ while(deq.size()>=2 && f(deq[0],i) >= f(deq[1],i)) deq.pop_front(); int idx=deq.front(); dp[i]=d[i-1]-(i-1)*a+(i-1)*i/2*b+f(idx,i); ca[i]=b*i,cb[i]=dp[i]+i*a+i*(i+1)/2*b; const int m=deq.size(); while(deq.size()>=2 && check(deq[m-2],deq[m-1],i)) deq.pop_back(); deq.push_back(i); } ll ans=inf; rep(i,n+1){ ll e=n-i; chmin(ans,dp[i]+b*e*(e+1)/2-a*e); } cout << ans << endl; return 0; }