#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;
int aa[105];
int a,b,c;
int dp[105][105];
int main() {
int n;
while(scanf("%d",&n) != EOF && n) {
int max = 0;
int min = 0x3f3f3f3f;
memset(aa,0x3f3f3f3f,sizeof(aa));
memset(dp,0x3f3f3f3f,sizeof(dp));
cin >> a >> c >> b;
for(int i = 1; i <= n; ++i) {
cin >> aa[i];
if(max < aa[i])
max = aa[i];
if(min > aa[i])
min = aa[i];
}
dp[0][min] = min*a;
for(int i = 1; i <= n; ++i) {
for(int j = aa[i]; j <= max; ++j) {
int t = 0x3f3f3f3f;
for(int k = min; k <= max; ++k) {
if(k >= j) {
int temp = dp[i-1][k] + (k-j)*b + c*j;
if(t > temp)
t = temp;
}
else {
int temp = dp[i-1][k] + (j-k)*a + c*j;
if(t > temp)
t = temp;
}
}
dp[i][j] = t;
}
}
int mmm = 0x3f3f3f3f;
for(int i = aa[n]; i <= max; i++) {
if(dp[n][i] < mmm)
mmm = dp[n][i];
}
cout << mmm << endl;
}
}
网友评论