var
i,sum,n,x:integer;
Begin
sum:= 0;
readln(n);
for i:=1 to n do begin
readln(x);
if(x mod 7 = 0) and (x mod 5 = 0) then
sum:=sum+x;
end;
writeln(sum);
End.
var
i,sum,n,x:integer;
Begin
sum:= 0;
readln(n);
for i:=1 to n do begin
readln(x);
if(x mod 7 = 0) and (x mod 5 = 0) then
sum:=sum+x;
end;
writeln(sum);
End.