// PascalABC.NET 3.6
begin
var n := ReadInteger;
ReadSeqInteger(n).Where(p -> p mod 10 = 6).Min.Print
end.
// PascalABC.NET 3.6
begin
var n := ReadInteger;
ReadSeqInteger(n).Where(p -> p mod 10 = 6).Min.Print
end.