//#define _GLIBCXX_DEBUG #include #define rep(i, n) for(int i=0; i; using vs = vector; using vi = vector; using vvi = vector; template using PQ = priority_queue; template using PQG = priority_queue, greater >; const int INF = 0xccccccc; const ll LINF = 0xcccccccccccccccLL; template inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);} template inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);} template istream &operator>>(istream &is, pair &p) { return is >> p.first >> p.second;} template ostream &operator<<(ostream &os, const pair &p) { return os << p.first << ' ' << p.second;} //head int main() { ios::sync_with_stdio(false); cin.tie(0); int n, a, b, w; cin >> n >> a >> b >> w; a <<= 1; b <<= 1; vi d(n); rep(i, n) cin >> d[i]; deque> dq; auto push = [&](ll nowtime, ll noww)->pair { return {-a - nowtime*b + (b>>1), a*nowtime + nowtime*(nowtime-1)*(b>>1) + noww}; }; auto val = [&](int i, ll nt) { auto [u, v] = dq[i]; return (b>>1)*nt*nt + u*nt + v; }; auto check = [&](pair &a, pair &b, pair &c) { return (c.second-b.second) * (b.first-a.first) < (b.second-a.second) * (c.first-b.first); }; dq.emplace_back(push(0, w<<1)); rep(i, n) { while(dq.size() > 1 and val(0, i) >= val(1, i)) dq.pop_front(); ll now = val(0, i) + (d[i]<<1); auto p = push(i+1, now); while(dq.size() > 1 and !check(dq[dq.size()-2], dq.back(), p)) dq.pop_back(); dq.emplace_back(p); } while(dq.size() > 1 and val(0, n) > val(1, n)) dq.pop_front(); cout << val(0, n)/2 << endl; } // o + ai - an + b(n-i)(n-i+1)/2 // o + n((b/2)n - a - ib + b/2) + ai + i(i-1)b/2 // (b/2)n^2 + (-a - ib + b/2)n + ai + i(i-1)b/2 + o