Var
n,tmp, i, max:integer;
fl:boolean;
begin
Read(n);
fl:=false;
max:= -1000*1000*1000-13;
for i:= 1 to n do
begin
Read(tmp);
if (tmp mod 3 = 0) then
begin
fl:= true;
if (max max:= tmp;
writeln(tmp, ' ');
end;
end;
if (fl) then Writeln('Максимальное: ', max)
else Writeln('NO');
end.