var
n:word;
a,max,i:integer;
begin
repeat
write ('N = ');readln(n);
until (n>0) and (n<=1000);</p>
write ('A = ');readln(a);
if a mod 5 = 0 then max:=a;
while i<>n-1 do begin
write ('A = ');readln(a);
if (a>max) and (a mod 5 = 0) then max:=a;
i:=i+1;
end;
writeln ('Max: ',max);
readln;
end.