#include using namespace std; #define int long long // <-----!!!!!!!!!!!!!!!!!!! #define rep(i,n) for (int i=0;i<(n);++i) #define rep2(i,a,b) for (int i=(a);i<(b);++i) #define rrep(i,n) for (int i=(n)-1;i>=0;--i) #define rrep2(i,a,b) for (int i=(a)-1;i>=b;--i) #define chmin(a,b) (a)=min((a),(b)); #define chmax(a,b) (a)=max((a),(b)); #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define printV(_v) cout<<(#_v)<<":";for(auto(_x):(_v)){cout<<" "<<(_x);}cout< inline void output(const First& first, const Rest&... rest) { cout << first << " "; output(rest...); } using ll = long long; using Pii = pair; using TUPLE = tuple; using vi = vector; using vvi = vector; using vvvi = vector; const int inf = 1ll << 60; const int mod = 1e9 + 7; using Graph = vector>; int N, A, B, W; int D[300010]; int deq[300010]; int dp[300010]; int a(int i) { return - i * B; } int b(int i) { return dp[i] + i * A + i * (i + 1) * B / 2; } int f(int i, int x) { return a(i) * x + b(i); } bool check(int f1, int f2, int f3) { int a1 = a(f1), b1 = b(f1); int a2 = a(f2), b2 = b(f2); int a3 = a(f3), b3 = b(f3); return (a2 - a1) * (b3 - b2) >= (b2 - b1) * (a3 - a2); } main() { std::ios::sync_with_stdio(false); std::cin.tie(0); cin >> N >> A >> B >> W; rep(i, N) cin >> D[i]; int s = 0, t = 1; deq[0] = 0; dp[0] = W; rep2(i, 1, N + 1) { dp[i] = D[i - 1] - (i - 1) * A + i * (i - 1) * B / 2 + f(deq[s], i); while (s + 1 < t && check(deq[t - 2], deq[t - 1], i)) t--; deq[t++] = i; while (s + 1 < t && f(deq[s], i + 1) >= f(deq[s + 1], i + 1)) s++; } int ans = inf; rep(i, N + 1) { chmin(ans, dp[i] - (N - i) * A + (N - i) * (N - i + 1) * B / 2); } cout << ans << endl; }