#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair i_i; typedef pair ll_i; typedef pair i_ll; typedef pair d_i; typedef pair ll_ll; typedef pair d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; double EPS = 1e-10; int main() { int N; ll A, B, W; cin >> N >> A >> B >> W; vector D(N); for (ll& x: D) scanf("%lld", &x); N++; D.push_back(0); int M = 1; vector p; p.push_back(i_ll(0, 0)); ll ans; for (ll i = 0; i < N; i++) { ll mi = p[0].second - B * i * p[0].first; ll lb = 0, ub = M - 1; while (ub - lb > 1) { ll mid = (lb + ub) / 2; ll x1 = p[mid].second - B * i * p[mid].first; ll x2 = p[mid + 1].second - B * i * p[mid + 1].first; if (x1 > x2) lb = mid; else ub = mid; mi = min(mi, min(x1, x2)); } mi += i*(i+1)/2 * B - i * A + D[i]; ans = mi; i_ll _p(i + 1, mi + i*(i+1)/2 * B + (i+1) * A); for (; M >= 2 && (double)(p[M - 1].second - p[M - 2].second) / (p[M - 1].first - p[M - 2].first) >= (double)(_p.second - p[M - 1].second) / (_p.first - p[M - 1].first); M--, p.pop_back()); M++; p.push_back(_p); } cout << W + ans << endl; }