var a,i,k,sum:integer;
begin
read(a);
for i:=1 to a do begin
read(k);
if(k mod 3 =0)and(k<150)then sum:=sum+k;
end;
write(sum);
end.