1 const inf=maxlongint;
2 type node=record
3 from,go,next,v,c:longint;
4 end;
5 var e:array[0..2000000] of node;
6 pre,head,q,d:array[0..1000000] of longint;
7 v:array[0..1000000] of boolean;
8 i,j,n,m,maxf,s,t,l,r,mincost,tot,a,b,fa,fb,f,x:longint;
9 function min(x,y:longint):longint;
10 begin
11 if x<y then exit(x) else exit(y);
12 end;
13 procedure ins(x,y,z,w:longint);
14 begin
15 inc(tot);
16 with e[tot] do
17 begin
18 from:=x;go:=y;v:=z;c:=w;next:=head[x];head[x]:=tot;
19 end;
20 end;
21 procedure insert(x,y,z,w:longint);
22 begin
23 ins(x,y,z,w);ins(y,x,0,-w);
24 end;
25 function spfa:boolean;
26 var i,x,y:longint;
27 begin
28 fillchar(v,sizeof(v),false);
29 for i:=s to t do d[i]:=inf;
30 l:=0;r:=1;q[1]:=s;d[s]:=0;v[s]:=true;
31 while l<r do
32 begin
33 inc(l);
34 x:=q[l];v[x]:=false;
35 i:=head[x];
36 while i<>0 do
37 begin
38 y:=e[i].go;
39 if (e[i].v<>0) and (d[x]+e[i].c<d[y]) then
40 begin
41 d[y]:=d[x]+e[i].c;
42 pre[y]:=i;
43 if not(v[y]) then
44 begin
45 v[y]:=true;
46 inc(r);
47 q[r]:=y;
48 end;
49 end;
50 i:=e[i].next;
51 end;
52 end;
53 exit(d[t]<>inf);
54 end;
55 procedure mcf;
56 var i,tmp:longint;
57 begin
58 mincost:=0;
59 while spfa do
60 begin
61 tmp:=inf;
62 i:=pre[t];
63 while i<>0 do
64 begin
65 tmp:=min(tmp,e[i].v);
66 i:=pre[e[i].from];
67 end;
68 inc(mincost,tmp*d[t]);
69 i:=pre[t];
70 while i<>0 do
71 begin
72 dec(e[i].v,tmp);
73 inc(e[i xor 1].v,tmp);
74 i:=pre[e[i].from];
75 end;
76 end;
77 end;
78 procedure init;
79 begin
80 tot:=1;
81 readln(n,a,b,f,fa,fb);
82 s:=0;t:=2*n+1;
83 for i:=1 to n do
84 begin
85 read(x);
86 insert(i+n,t,x,0);
87 insert(s,i,x,0);
88 insert(s,i+n,x,f);
89 if i+1<=n then insert(i,i+1,inf,0);
90 if i+a+1<=n then insert(i,i+a+n+1,inf,fa);
91 if i+b+1<=n then insert(i,i+b+n+1,inf,fb);
92 end;
93
94 end;
95 procedure main;
96 begin
97 mincost:=0;
98 mcf;
99 writeln(mincost);
100 end;
101 begin
102 assign(input,‘input.txt‘);assign(output,‘output.txt‘);
103 reset(input);rewrite(output);
104 init;
105 main;
106 close(input);close(output);
107 end.