var a,s: integer;
begin
readln(a);
while (a > 0) do begin
if (a mod 6 = 0) then
s:=s+a;
end;
writeln(s);
end.
var a,s: integer;
begin
readln(a);
while (a > 0) do begin
readln(a);
if (a mod 6 = 0) then
s:=s+a;
end;
writeln(s);
end.