#include using namespace std; const int N = (int) 3e5 + 1; int a, b, w, d[N], n; long long f[N]; struct Line { long long a, b; // ax + b double lim; double cut(const Line &other) { return -(b - other.b) / (double) (a - other.a); } long long x(int z) { return a * z + b; } }; int main() { ios::sync_with_stdio(false); cin >> n >> a >> b >> w; for (int i = 1; i <= n; ++i) cin >> d[i]; if (b == 0) { cout << w - 1LL * a * n << endl; return 0; } vector lines; lines.push_back({0, 0, 1e50}); int ptr = 0; for (int i = 1; i <= n; ++i) { ptr = min(ptr, (int) lines.size() - 1); while (i > lines[ptr].lim) ++ptr; f[i] = lines[ptr].x(i) - 1LL * i * a + i * (i + 1LL) / 2 * b; long long another = f[i - 1] + d[i]; Line d1 = {-1LL * i * b, another + 1LL * i * a + i * (i - 1LL) / 2 * b, 1e50}; while (lines.size() > 1 && d1.cut(lines[lines.size() - 1]) <= d1.cut(lines[lines.size() - 2])) lines.pop_back(); lines.back().lim = d1.cut(lines.back()); lines.push_back(d1); f[i] = min(f[i], another); } cout << f[n] + w << '\n'; return 0; }