Var
a:array[1..10000] of integer;
i, n, first, last:integer;
fl: boolean;
begin
Read(n);
For i:= 1 to n do
Read(a[i]);fl:=false;
For i:= 1 to n do
if (a[i] mod 5 = 0) then
if (fl = false) then begin
fl:= true;
first := i;
last:= i;
end
else
last := i;
Writeln('Первый -> ', first);
Writeln('Последный -> ', last);
end.