var s : array[1..1000] of integer;
d : array[1..1000] of integer;
e : array[1..1000] of integer;
f : array[1..1000] of integer;
a,i,i1,i2,i3,n: integer;
begin
i1 := 0;
i2 := 0;
i3 := 0;
Writeln('nhap so phan tu cua day: '); read(n);
for i:=1 to n do
begin
Write('So thu ',i,': ');read(a);
s[i] := a;
end;
for i:= 1 to n do
begin
if s[i] mod 3 = 0 then
begin
i1 := i1 + 1;
d[i1] := s[i];
end;
if s[i] mod 3 = 1 then
begin
i2 := i2 + 1;
e[i2] := s[i];
end;
if s[i] mod 3 = 2 then
begin
i3 := i3 + 1;
f[i3] := s[i];
end;
end;
for i:= 1 to i1 do Writeln('so chia het cho 3: ',d[i]);
for i:= 1 to i2 do Writeln('so chia cho 3 du 1: ',e[i]);
for i:= 1 to i3 do Writeln('so chia cho 3 du 2: ',f[i]);
end.