#include <iostream> #include <deque> #include <algorithm> #define rep(i, n) for(int i = 0; i < (n); ++i) using namespace std; typedef long long ll; typedef __int128 lll; const ll inf = 1e12; int n, a, b, w; int d[300000]; ll dp[300001]; deque<int> k; ll pt(int k){ return -ll(k) * b; } ll ct(int k){ return dp[k] + ll(k) * a + k * ll(k + 1) / 2 * b; } ll f(int k, int x){ return pt(k) * x + ct(k); } bool rm(int p, int q, int r){ return lll(ct(q) - ct(r)) * (pt(p) - pt(q)) >= lll(ct(p) - ct(q)) * (pt(q) - pt(r)); } void calc(){ dp[0] = w; for(int i = 1; i <= n; ++i){ while(k.size() >= 2 && rm(k[k.size() - 2], k.back(), i - 1)){ k.pop_back(); } k.push_back(i - 1); while(k.size() >= 2 && f(k[0], i) >= f(k[1], i)){ k.pop_front(); } dp[i] = f(k[0], i) + d[i - 1] + i * ll(i - 1) / 2 * b - ll(i - 1) * a; } } int main(){ cin >> n >> a >> b >> w; rep(i, n){ cin >> d[i]; } calc(); ll ans = inf; rep(i, n + 1){ ans = min(dp[n - i] + i * ll(i + 1) / 2 * b - ll(i) * a, ans); } cout << ans << endl; return 0; }