1 #include <bits/stdc++.h>
2 using namespace std;
3
4 const int maxn=1000+5,INF=1<<27;
5 int cnt=1;
6 int head[maxn<<1],q[maxn<<1],d[maxn<<1],p[maxn<<1];
7 bool vis[maxn<<1];
8
9 struct edge{
10 int from,to,cap,cost,next;
11 edge(){}
12 edge(int from,int to,int cap,int cost,int next):from(from),to(to),cap(cap),cost(cost),next(next){}
13 }g[maxn*maxn];
14 void add_edge(int u,int v,int cap,int cost){
15 g[++cnt]=edge(u,v,cap,cost,head[u]); head[u]=cnt;
16 g[++cnt]=edge(v,u,0,-cost,head[v]); head[v]=cnt;
17 }
18 bool spfa(int s,int t){
19 for(int i=s;i<=t;i++) d[i]=INF, vis[i]=false;
20 d[s]=0; vis[s]=true;
21 int front=0,tail=0;
22 q[tail++]=s;
23 while(front!=tail){
24 int u=q[front++]; if(front==2001) front=0;
25 vis[u]=false;
26 for(int i=head[u];i;i=g[i].next) if(g[i].cap&&d[g[i].to]>d[u]+g[i].cost){
27 d[g[i].to]=d[u]+g[i].cost;
28 p[g[i].to]=i;
29 if(!vis[g[i].to]){
30 vis[g[i].to]=true;
31 q[tail++]=g[i].to; if(tail==2001) tail=0;
32 }
33 }
34 }
35 return d[t]!=INF;
36 }
37 int min_cost(int s,int t){
38 int ret=0,f;
39 while(spfa(s,t)){
40 f=INF;
41 for(int u=t;u!=s;u=g[p[u]].from) f=min(f,g[p[u]].cap);
42 for(int u=t;u!=s;u=g[p[u]].from) g[p[u]].cap-=f, g[p[u]^1].cap+=f;
43 ret+=d[t]*f;
44 }
45 return ret;
46 }
47 int main(){
48 int n,a,b,f,fa,fb;
49 scanf("%d%d%d%d%d%d",&n,&a,&b,&f,&fa,&fb);
50 int s=0,t=(n<<1)+1;
51 for(int i=1;i<=n;i++){
52 if(i+1<=n) add_edge(i,i+1,INF,0);
53 if(i+a+1<=n) add_edge(i,n+i+a+1,INF,fa);
54 if(i+b+1<=n) add_edge(i,n+i+b+1,INF,fb);
55 add_edge(0,n+i,INF,f);
56 }
57 for(int i=1;i<=n;i++){
58 int r; scanf("%d",&r);
59 add_edge(s,i,r,0);
60 add_edge(n+i,t,r,0);
61 }
62 printf("%d\n",min_cost(s,t));
63 return 0;
64 }