{ sprendimo autorius: Vilius Visockas }

program mess;
const
  fin = '';
  max = 10000000;
  dm = 1000010;
type
  Tmas = array [0 .. dm] of longint;
var
  mas1, mas2: Tmas;
  f: text;
  i, best, n, dd, temp1: longint;

PROCEDURE quicksort (VAR A : Tmas; l,r: INTEGER);
VAR m: INTEGER;

   FUNCTION Divide(VAR A: Tmas; l,r: INTEGER): INTEGER;
   VAR pivot,i,j :  INTEGER;

       PROCEDURE Vertausche(VAR A: Tmas;s,t: INTEGER);
       VAR b : INTEGER;
       BEGIN
          b:=A[s]; A[s]:=A[t]; A[t]:=b
       END; { Vertausche }

   BEGIN { Divide }
      pivot := A[r];
      i := l-1;
      j := r+1;
      REPEAT
	 REPEAT i := i+1 UNTIL pivot <= A[i];
         REPEAT j := j-1 UNTIL pivot >= A[j];
         Vertausche(A,i,j)
      UNTIL j <= i;

      Vertausche(A,i,j); (* mache letzte Vertauschung der Repeat-Schleife *)
                         (* rueckgaengig, da dort bereits j <= i galt.    *)
      Divide := i        (* Aufteilung von A ist A[l..i-1] und A[i..r].   *)
   END; { Divide }

BEGIN { Quicksort }
   IF l < r THEN
   BEGIN
      m := Divide(A,l,r);
      Quicksort(A,l,m-1);
      Quicksort(A,m,r)
   END
END; { Quicksort }


begin
  assign (f, fin);
  reset (f);
  best := max;
  readln (f, n);
  for i := 0 to n - 1 do begin
    read (f, dd);
    mas1 [i] := (i + 1 + n - dd) mod n;
    mas2 [i] := (i + dd) mod n;
  end;
  quicksort (mas1, 0, n - 1);
  quicksort (mas2, 0, n - 1);
  for i := 0 to n - 2 do begin
    temp1 := (mas1 [i] - mas1 [i + 1] + 2*n - 1) mod n + 1;
    if (temp1 < best) then best := temp1;
    temp1 := (mas2 [i] - mas2 [i + 1] + 2*n - 1) mod n + 1;
    if (temp1 < best) then best := temp1;
  end;

  temp1 := (mas1 [n - 1] - mas1 [0] + 2*n) mod n;
  if (temp1 < best) then best := temp1;
  temp1 := (mas2 [n - 1] - mas2 [0] + 2*n) mod n;
  if (temp1 < best) then best := temp1;
  writeln ((best + 1) div 2);
end.
