programm p;
var
a:array[1..100 ] of integer;
i,n:integer;
s:integer;
begin
readln n;
for i:=1 to n do
readln(a[i]);
s:=0;
if (a[i]>5)and(a[i]<81)and(a[i]/7=int a[i]/7) then
s:=s+a[i];
if a[i]= 0 then break;
end;
writeln(s);
end.
programm p;
var
a:array[1..100 ] of integer;
i,n:integer;
s:integer;
begin
readln n;
for i:=1 to n do
readln(a[i]);
s:=0;
for i:=1 to n do
begin
if (a[i]>5)and(a[i]<81)and(a[i]/7=int a[i]/7) then
s:=s+a[i];
if a[i]= 0 then break;
end;
writeln(s);
end.