program mas_min_krat3;
var
i,n,m,x:integer;
begin
read(n);
m:=30000;
for i:=1 to n do
read(x);
if (x<m)and(x mod 3=0) then m:=x;
end;
writeln(m);
end.
### PascalABC.NET ###
var A := ReadSeqInteger('вводи: ', ReadInteger('длина посл-ти: '));
A.Where(p -> p mod 3 = 0).Min.Println;
program mas_min_krat3;
var
i,n,m,x:integer;
begin
read(n);
m:=30000;
for i:=1 to n do
begin
read(x);
if (x<m)and(x mod 3=0) then m:=x;
end;
writeln(m);
end.
### PascalABC.NET ###
begin
var A := ReadSeqInteger('вводи: ', ReadInteger('длина посл-ти: '));
A.Where(p -> p mod 3 = 0).Min.Println;
end.