#include using namespace std; using ll = long long; using pll = pair; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second const ll MOD = 1000000007; const ll MOD2 = 998244353; const ll INF = 1LL << 60; const ll MAX_N = 2e5; deque deq; ll N, A, B, W; bool check(pll f1, pll f2, pll f3){ return (f2.fi-f1.fi)*(f3.se-f2.se) >= (f2.se-f1.se)*(f3.fi-f2.fi); } void add(pll conf2){ while((ll)deq.size()>=2){ pll conf1 = deq.back(); deq.pop_back(); pll conf0 = deq.back(); if(!check(conf0, conf1, conf2)){ deq.push_back(conf1); break; } } deq.push_back(conf2); } ll f(pll coef, ll x){ return (coef.fi*x + coef.se);} ll query(ll x){ while((ll)deq.size()>=2){ pll coef0 = deq.front(); deq.pop_front(); pll coef1 = deq.front(); deq.pop_front(); if(f(coef0, x) >= f(coef1, x)){ deq.push_front(coef1); }else{ deq.push_front(coef1); deq.push_front(coef0); break; } } return f(deq.front(), x); } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin >> N >> A >> B >> W; vector D(N+1); for(ll i=1; i<=N; i++) cin >> D[i]; vector dp(N+1); dp[0] = W; add({B-2*A, 2*W}); for(ll i=1; i<=N; i++){ add({B-2*B*i-2*A, B*i*i-B*i+2*A*i+2*dp[i-1]+2*D[i]}); dp[i] = (B*i*i+query(i))/2; } cout << dp[N] << endl; }