#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define repeat(i,n) for (int i = 0; (i) < (n); ++ (i)) #define debug(x) cerr << #x << ": " << x << '\n' #define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n' #define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n' using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair Pii; typedef vector vint; typedef vector vll; const int INF = INT_MAX; const ll MOD = 1e9+7; template class ConvexHullTrick { private: vector > lines; int head; bool check(pair l1, pair l2, pair l3) { return (l3.second - l2.second) * (l2.first - l1.first) >= (l2.second - l1.second) * (l3.first - l2.first); } T f(int i, T x) { return lines[i].first * x + lines[i].second; } public: ConvexHullTrick():head(0){} void insert(T a, T b) { pair line(a, b); while (lines.size()-head >= 2 && check(*(lines.end() - 2), lines.back(), line)) lines.pop_back(); lines.emplace_back(line); } T getmin(T x) { while (lines.size() - head >= 2 && (f(head, x)>=f(head + 1, x))) ++head; return f(head, x); } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; ll A,B,W; cin>>N>>A>>B>>W; ConvexHullTrick CHT; CHT.insert(-B,2*W); for(ll i=1;i<=N;i++){ ll D;cin>>D; ll dp=(CHT.getmin(i)+B*i*i-2*A*(i-1)+2*D)/2; CHT.insert(-B*(1+2*i),B*(i+1)*i+2*A*i+2*dp); } cout<<(CHT.getmin(N+1)+B*(N+1)*(N+1)-2*A*(N))/2<