var
i, n, m, k, t: Integer;
a: array [1..9] of Integer;
begin
Read(n);
for i:=1 to n do begin
Read(t);
case t in
1..36: a[1+(t-1) div 4]:=1;
37..54: a[(56-t) div 2]:=1;
end;
end;
for i:=1 to 9 do begin
if a[i]=0 then Inc(k) else k:=0;
if m<k then m:=k;
end;
WriteLn(m);
end.