var m,n,i: integer;
a:array[1..10000] of integer;
begin
write('Nhap so n = '); readln(n);
for i:=1 to n do
begin
write('a[',i,'] = '); readln(a[i]);
end;
for i:=1 to n do
if a[i] = 2004 then m:=m+1;
if m>=1 then write(2004) else write(-1);
end.
Program HOC24;
var n,i,d: integer;
a: array[1..32000] of integer;
begin
write('n = '); readln(n);
d:=0;
for i:=1 to n do
begin
write('Nhap so thu ',i,' : ');
readln(a[i]);
if a[i]=2004 then d:=d+1;
end;
if d<>0 then write(2004) else write(-1);
readln
end.