1 #include<bits/stdc++.h>
2 #define inf 2147483647
3 #define rep(i,l,r) for(int i=l;i<=r;i++)
4 #define N 10050
5 using namespace std;
6 struct Edge{
7 int to,next,from,c,w;
8 }e[5000000];
9 int head[N],tot=1,ans,dis[N],from[N],r[N],n,T,a,b,f,fa,fb,c,s[N];
10 bool used[N];
11 inline void ins(int u,int v,int w,int cost) {
12 e[++tot].to=v; e[tot].next=head[u]; head[u]=tot; e[tot].w=w; e[tot].c=cost; e[tot].from=u;
13 }
14 inline void insert(int u,int v,int w,int cost) {
15 ins(u,v,w,cost); ins(v,u,0,-cost);
16 }
17 inline bool spfa() {
18 queue<int> q; for(int i=0;i<=T;i++) dis[i]=inf; dis[0]=0; q.push(0); used[0]=1;
19 while(!q.empty()) {
20 int x=q.front(); q.pop();
21 for(int k=head[x];k;k=e[k].next)
22 if(e[k].w>0&&dis[x]+e[k].c<dis[e[k].to]){
23 dis[e[k].to]=dis[x]+e[k].c; from[e[k].to]=k;
24 if(!used[e[k].to]) {
25 used[e[k].to]=1; q.push(e[k].to);
26 }
27 }
28 used[x]=0;
29 }
30 if(dis[T]==inf) return 0;else return 1;
31 }
32
33 inline void run() {
34 int x=inf;
35 for(int k=from[T];k;k=from[e[k].from]) x=min(x,e[k].w);
36 for(int k=from[T];k;k=from[e[k].from]) {
37 e[k].w-=x; e[k^1].w+=x; ans+=e[k].c*x;
38 }
39 }
40
41 inline int read() {
42 int x=0; char ch=getchar();
43 while(ch<‘0‘ || ch>‘9‘) ch=getchar();
44 while(ch>=‘0‘ && ch<=‘9‘) x=x*10+ch-48,ch=getchar();
45 return x;
46 }
47 int main () {
48 scanf("%d%d%d%d%d%d",&n,&a,&b,&f,&fa,&fb);
49 T=n+n+1;
50 rep(i,1,n) scanf("%d",&s[i]);
51 rep(i,1,n) insert(0,i,s[i],0),insert(i+n,T,s[i],0),insert(0,i+n,inf,f);
52 rep(i,1,n-1) insert(i,i+1,inf,0);
53 rep(i,1,n) {
54 if(i+a<n) insert(i,i+n+a+1,inf,fa);
55 if(i+b<n) insert(i,i+n+b+1,inf,fb);
56 }
57 while(spfa()) run();
58 printf("%d",ans);
59 }