var max,n,i,j,k,k0,k1,k2:longint;
a,b,c,d,e:array[0..500]of longint;
dp:array[0..500]of longint;
sum:array[1..14]of longint;
procedure deal;
var temp,xx:longint;
begin
randomize;
repeat
xx:=random(n)+1;
until (xx>=1) and(xx<=n);
temp:=sum[xx];sum[xx]:=sum[1];sum[1]:=temp;
end;
begin
assign(input,'asm_grenade.in');
assign(output,'asm_grenade.out');
reset(input);
rewrite(output);
fillchar(dp,sizeof(dp),0);
max:=-maxlongint;
read(n);
for i:=1 to n do
read(a[i]);
for i:=1 to n do
read(b[i]);
for i:=1 to n do
read(c[i]);
for i:=1 to n do
read(d[i]);
for i:=1 to n do
read(e[i]);
read(k0,k1,k2);
for i:=1 to n do sum[i]:=i;
deal;
dp[0]:=k0+k1+k2;
for i:=1 to n do
for j:=k0+k2+k1 downto a[sum[i]]+b[sum[i]] do
for k:=k1+k2+k0 downto b[sum[i]]+a[sum[i]] do
if (j-a[sum[i]]-b[sum[i]]>=0)and(k-b[sum[i]]-a[sum[i]]>=0)then
if dp[j+k]<dp[j-a[sum[i]]+k-b[sum[i]]]+d[sum[i]]+c[sum[i]]+e[sum[i]] then
dp[j+k]:=dp[j-a[sum[i]]+k-b[sum[i]]]+d[sum[i]]+c[sum[i]]+e[sum[i]];
for i:=0 to 2*(k1+k2+k0) do
if dp[i]>max then max:=dp[i];
write(dp[i]);
close(input);
close(output);
end.