uses crt;
var a:array[1..250] of integer;
i,n,s,t:integer;
begin
write('nhap n='); readln(n);
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
end;
writeln('thu tu nguoc lai cua thu tu nhap la:');
for i:=n downto 1 do writeln('a[',i,']=',a[i],' ');
s:=0; t:=0;
for i:=1 to n do if a[i] mod 3=0 then s:=s+a[i]*a[i];
for i:=1 to n do if a[i] mod 5=0 then t:=t+a[i]*a[i];
writeln('tong binh phuong cac so chia het cho 3 la:',s);
write('tong binh phuong cac so chia het cho 5 la:',t);
readln
end.