uses crt;
type mang=array[1..499]of integer;
var a:mang;
i,n,t,t1:integer;
{--------------------------------thu-tuc-nhap-----------------------}
procedure nhap;
begin
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
end;
end;
{-------------------------------ham-kiem-tra-so-chia-het------------------------}
function ktch(var x:integer):boolean;
var kt:boolean;
begin
kt:=false;
if (x mod 3=0) and (x mod 5=0) then kt:=true;
ktch:=kt;
end;
{-------------------------------chuong-trinh-chinh--------------------------}
begin
clrscr;
write('nhap n='); readln(n);
nhap;
t:=0;
for i:=1 to n do
begin
t1:=a[i];
if ktch(t1) then t:=t+t1;
end;
writeln(t);
readln;
end.