1 #include<iostream>
2 #include<string>
3 #include<algorithm>
4 #include<cstdio>
5 #include<cstring>
6 #include<cstdlib>
7 #include<cmath>
8 using namespace std;
9 typedef long long s64;
10
11 const int ONE = 1000001;
12 const int EDG = 1000001;
13 const int INF = 2147483640;
14
15 int n,a,b,f,fA,fB;
16 int x;
17 int X[ONE],Y[ONE];
18 int S,T;
19 int next[EDG],first[ONE],go[EDG],from[EDG],pas[EDG],w[EDG],tot;
20 int dist[ONE],pre[ONE],vis[ONE];
21 int tou,wei,q[ONE];
22 int Ans;
23
24 inline int get()
25 {
26 int res=1,Q=1; char c;
27 while( (c=getchar())<48 || c>57)
28 if(c==‘-‘)Q=-1;
29 if(Q) res=c-48;
30 while((c=getchar())>=48 && c<=57)
31 res=res*10+c-48;
32 return res*Q;
33 }
34
35 void Add(int u,int v,int flow,int z)
36 {
37 next[++tot]=first[u]; first[u]=tot; go[tot]=v; from[tot]=u; pas[tot]=flow; w[tot]=z;
38 next[++tot]=first[v]; first[v]=tot; go[tot]=u; from[tot]=v; pas[tot]=0; w[tot]=-z;
39 }
40
41 bool Bfs()
42 {
43 for(int i=S;i<=T;i++) dist[i] = INF;
44 dist[S] = 0; vis[S] = 1;
45 tou = 0; wei = 1; q[1] = S;
46 while(tou < wei)
47 {
48 int u = q[++tou];
49 for(int e=first[u]; e; e=next[e])
50 {
51 int v = go[e];
52 if(dist[v] > dist[u] + w[e] && pas[e])
53 {
54 dist[v] = dist[u] + w[e]; pre[v] = e;
55 if(!vis[v])
56 {
57 vis[v] = 1;
58 q[++wei] = v;
59 }
60 }
61 }
62 vis[u] = 0;
63 }
64 return dist[T] != INF;
65 }
66
67 void Deal()
68 {
69 int x = INF;
70 for(int e=pre[T]; e; e=pre[from[e]]) x = min(x,pas[e]);
71 for(int e=pre[T]; e; e=pre[from[e]])
72 {
73 pas[e] -= x;
74 pas[((e-1)^1)+1] += x;
75 Ans += x*w[e];
76 }
77 }
78
79 int main()
80 {
81 n=get(); a=get(); b=get();
82 f=get(); fA=get(); fB=get();
83 S=0; T=n*2+5;
84 for(int i=1;i<=n;i++) X[i]=i, Y[i]=i+n;
85 for(int i=1;i<=n;i++)
86 {
87 x = get();
88 Add(S,X[i], x,0);
89 Add(Y[i],T, x,0);
90 Add(S,Y[i], INF,f);
91 if(i!=n) Add(X[i],X[i+1], INF,0);
92 if(Y[i]+a+1 < T)Add(X[i],Y[i]+a+1, INF,fA);
93 if(Y[i]+b+1 < T)Add(X[i],Y[i]+b+1, INF,fB);
94 }
95
96 while(Bfs()) Deal();
97 printf("%d",Ans);
98
99 }