#include using namespace std; typedef long long LL; typedef __int128 INT; /*cin高速化*/ struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init; ostream& operator<<(ostream &os,INT x){ LL y; y=x; assert(y==x); os << y; return os; } istream& operator>>(istream &is,INT& x){ LL y; is >> y; x = y; return is; } const INT INF = 1e24; namespace CHT{ using TYPE=INT; #define A first #define B second #define SIZE 1000000 pair mem[SIZE]; template inline bool is_minimam(T a1,T b1,T a2,T b2,T a3,T b3){return (a2-a1)*(b3-b2)>=(b2-b1)*(a3-a2);} template inline bool is_maximam(T a1,T b1,T a2,T b2,T a3,T b3){return is_minimam(-a1,-b1,-a2,-b2,-a3,-b3);} template inline bool check(pair L1,pair L2,pair L3){ return is_minimam(L1.A,L1.B,L2.A,L2.B,L3.A,L3.B); } template inline T calc(pair L,T now){ return L.A*now+L.B; } }; template ostream& operator<<(ostream& os,pair t){ os <<"("<< t.first << " "< class convex_hull_trick{ pair *deque; int s,t; public: convex_hull_trick(pair *mem):deque(mem),s(0),t(0){} convex_hull_trick():convex_hull_trick(CHT::mem){} void add(T a,T b){ auto L=mp(a,b); while(s+1=CHT::calc(deque[s+1],now))s++; return CHT::calc(deque[s],now); } void pop(){ while(s+1=CHT::calc(deque[s+1]))s++; } }; int main() { INT N,A,B,W; /*input N,A,B,W*/ { cin >> N >> A >> B >> W; assert(1 <= N && N <= 300000); assert(0 <= A && A <= 1000000); assert(0 <= B && B <= 1000000); assert(0 <= W && W <= 1000000); } vector D(N); { for(auto& it : D){ cin >> it; assert(0 <= it && it <= 1000000); } } /*DP*/ convex_hull_trick deq; vector dp(N+1,INF); dp[0] = W; deq.add( - 0 * B,dp[0] + 0 * A + B * 0 * (0 - 1) / 2); for(int i = 0; i < N; i++){ dp[i + 1] = D[i] - i * A + ( B * i * (i + 1)) / 2 + deq.get(i); deq.add( - (i + 1) * B , dp[i + 1] + (i + 1) * A + ( B * (i + 1) * i) / 2); } /*output*/ INT res = INF; for(int i = 0; i <= N; i++) res = min(res,dp[i] - A * (N -i) + B * (N - i) * (N - i + 1) / 2); cout << res << endl; return 0; }