uses crt;
var a:array[1..100]of integer;
n,i,t:integer;
begin
clrscr;
randomize;
write('Nhap n='); readln(n);
for i:=1 to n do
a[i]:=random(999)+1;
t:=0;
for i:=1 to n do
if a[i] mod 3=0 then t:=t+a[i];
writeln('Tong cac phan tu chia het cho 3 la: ',t);
readln;
end.