#include using namespace std; #define rep(i,n) for(ll i=0;i=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue,greater> #define all(x) (x).begin(),(x).end() #define CST(x) cout<; using vvl=vector>; using pl=pair; using vpl=vector; using vvpl=vector; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=2e9+1; const ll INF=4e18; const ll dy[8]={-1,0,1,0,1,1,-1,-1}; const ll dx[8]={0,-1,0,1,1,-1,1,-1}; template inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); } template inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); } template> vector> monotone_minima(int H,int W,const function &f,const Compare &comp=Compare()){ vector> dp(H); function dfs=[&](int top,int bottom,int left,int right){//閉区間で実装 if(top>bottom)return; int line=(top+bottom)/2; T val=f(line,left); int idx=left; for(int i=left;i<=right;i++){ T nowval=f(line,i); if(comp(nowval,val)){ val=nowval; idx=i; } } dp[line]=make_pair(idx,val); dfs(top,line-1,left,idx); dfs(line+1,bottom,idx,right); }; dfs(0,H-1,0,W-1); return dp; } ll n,a,b,w; vl dp,d,fin; ll basej,basei; auto fx=[](ll i,ll j){ ll len=(basei+i)-(basej+j)-1; return dp[basej+j]-a*len+len*(len+1)/2*b; }; void induce(ll l,ll m,ll r){ basei=m;basej=l; for(int i=l;i(r-m,m-l,fx); for(int i=m;i> n >> a >> b >> w; d.resize(n+2);dp.resize(n+2,INF);fin.resize(n+2); dp[0]=w; rep(i,n)cin >> d[i+1]; solve(0,n+2); cout << dp.back() << endl; }