#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define fi first
#define se second
#define task "PROJECT"
//#define task "task"
#define all(x) (x).begin(), (x).end()
using namespace std;
int n, h, s, d;
vector<int> a;
void ip() {
cin >> n >> h >> s >> d;
for(int i = 0; i < n; ++i) {
int ai; cin >> ai; a.push_back(ai);
}
ll ans = 0;
stack<ii> pq;
int cur = 0;
for(int i = 0; i < n; ++i) {
if(cur < a[i]) {
int numHire = a[i] - cur;
while(true) {
if(!pq.size()) break;
if(numHire == 0) break;
int num = pq.top().se, tim = pq.top().fi; pq.pop();
ll t0 = 1LL * (i - tim) * s;
ll t1 = h + d;
int used = min(num, numHire); num -= used;
if(t0 < t1) {
// cout << "waiting: " << t0 << " " << used << '\n';
ans += t0 * used;
ans -= 1LL * d * used;
numHire -= used;
if(num > 0)pq.push({tim, num});
}
else {
while(pq.size()) pq.pop();
break;
}
}
if(numHire > 0) {
ans += 1LL * numHire * h;
}
}
else if(cur > a[i]) {
// cout << "queue: " << i << " " << cur - a[i] << '\n';
ans += 1LL * d * (cur - a[i]);
pq.push({i, cur - a[i]});
}
ans += 1LL * a[i] * s;
cur = a[i];
// cout << i << " " << ans << '\n';
}
ans += 1LL * cur * d;
cout << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
if(fopen(task".INP", "r")){
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
int tt = 1;
// cin >> tt;
while(tt--) {
ip();
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KI2RlZmluZSBsbCBsb25nIGxvbmcKI2RlZmluZSBpaSBwYWlyPGludCwgaW50PgojZGVmaW5lIGZpIGZpcnN0CiNkZWZpbmUgc2Ugc2Vjb25kCiNkZWZpbmUgdGFzayAiUFJPSkVDVCIKLy8jZGVmaW5lIHRhc2sgInRhc2siCgojZGVmaW5lIGFsbCh4KSAoeCkuYmVnaW4oKSwgKHgpLmVuZCgpCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG4sIGgsIHMsIGQ7CnZlY3RvcjxpbnQ+IGE7CnZvaWQgaXAoKSB7CiAgICBjaW4gPj4gbiA+PiBoID4+IHMgPj4gZDsKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgICAgICBpbnQgYWk7IGNpbiA+PiBhaTsgYS5wdXNoX2JhY2soYWkpOwogICAgfQogICAgbGwgYW5zID0gMDsKICAgIHN0YWNrPGlpPiBwcTsKICAgIGludCBjdXIgPSAwOwogICAgZm9yKGludCBpID0gMDsgaSA8IG47ICsraSkgewogICAgICAgIGlmKGN1ciA8IGFbaV0pIHsKICAgICAgICAgICAgaW50IG51bUhpcmUgPSBhW2ldIC0gY3VyOwoKICAgICAgICAgICAgd2hpbGUodHJ1ZSkgewogICAgICAgICAgICAgICAgaWYoIXBxLnNpemUoKSkgYnJlYWs7CiAgICAgICAgICAgICAgICBpZihudW1IaXJlID09IDApIGJyZWFrOwogICAgICAgICAgICAgICAgaW50IG51bSA9IHBxLnRvcCgpLnNlLCB0aW0gPSBwcS50b3AoKS5maTsgcHEucG9wKCk7CiAgICAgICAgICAgICAgICBsbCB0MCA9IDFMTCAqIChpIC0gdGltKSAqIHM7CiAgICAgICAgICAgICAgICBsbCB0MSA9IGggKyBkOwogICAgICAgICAgICAgICAgaW50IHVzZWQgPSBtaW4obnVtLCBudW1IaXJlKTsgbnVtIC09IHVzZWQ7CiAgICAgICAgICAgICAgICBpZih0MCA8IHQxKSB7Ci8vICAgICAgICAgICAgICAgICAgICBjb3V0IDw8ICJ3YWl0aW5nOiAiIDw8IHQwIDw8ICIgIiA8PCB1c2VkIDw8ICdcbic7CiAgICAgICAgICAgICAgICAgICAgYW5zICs9IHQwICogdXNlZDsKICAgICAgICAgICAgICAgICAgICBhbnMgLT0gMUxMICogZCAqIHVzZWQ7CiAgICAgICAgICAgICAgICAgICAgbnVtSGlyZSAtPSB1c2VkOwogICAgICAgICAgICAgICAgICAgIGlmKG51bSA+IDApcHEucHVzaCh7dGltLCBudW19KTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UgewogICAgICAgICAgICAgICAgICAgIHdoaWxlKHBxLnNpemUoKSkgcHEucG9wKCk7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYobnVtSGlyZSA+IDApIHsKICAgICAgICAgICAgICAgIGFucyArPSAxTEwgKiBudW1IaXJlICogaDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBlbHNlIGlmKGN1ciA+IGFbaV0pIHsKLy8gICAgICAgICAgICBjb3V0IDw8ICJxdWV1ZTogIiA8PCBpIDw8ICIgIiA8PCBjdXIgLSBhW2ldIDw8ICdcbic7CiAgICAgICAgICAgIGFucyArPSAxTEwgKiBkICogKGN1ciAtIGFbaV0pOwogICAgICAgICAgICBwcS5wdXNoKHtpLCBjdXIgLSBhW2ldfSk7CiAgICAgICAgfQogICAgICAgIGFucyArPSAxTEwgKiBhW2ldICogczsKICAgICAgICBjdXIgPSBhW2ldOwovLyAgICAgICAgY291dCA8PCBpIDw8ICIgIiA8PCBhbnMgPDwgJ1xuJzsKICAgIH0KICAgIGFucyArPSAxTEwgKiBjdXIgKiBkOwogICAgY291dCA8PCBhbnM7Cn0KaW50IG1haW4oKSB7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKDApOwogICAgY2luLnRpZSgwKSwgY291dC50aWUoMCk7CiAgICBpZihmb3Blbih0YXNrIi5JTlAiLCAiciIpKXsKICAgICAgICBmcmVvcGVuKHRhc2siLklOUCIsICJyIiwgc3RkaW4pOwogICAgICAgIGZyZW9wZW4odGFzayIuT1VUIiwgInciLCBzdGRvdXQpOwogICAgfQogICAgaW50IHR0ID0gMTsKLy8gICAgY2luID4+IHR0OwogICAgd2hpbGUodHQtLSkgewogICAgICAgIGlwKCk7CiAgICB9Cn0K