#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; void add(ll a, ll b, ll c){ deq.push_back({a, b, c}); } ll f(tuple coef, ll x){ ll a = get<0>(coef); ll b = get<1>(coef); ll c = get<2>(coef); return (a*x*x + b*x+c)/2; } ll query(ll x){ while(deq.size()>=2){ tuple coef0 = deq.front(); deq.pop_front(); tuple 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, B-2*A, 2*W); for(ll i=1; i<=N; i++){ dp[i] = query(i); add(B, B-2*B*i-2*A, B*i*i-B*i+2*A*i+2*dp[i-1]+2*D[i]); } cout << dp[N] << endl; }