program Hello;
var i, s, nr, n:integer;
begin
write ('Din cate numere va fi formatul sirul?:');
read(n);
writeln('Dati numerele:');
s:=0;
for i:=1 to n do begin
readln(nr);
if (nr mod 3 = 0) OR (nr mod 5 = 0) then begin
s:=s+nr;
end;
end;
writeln('S=',s);
end.