import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class _483 { public static void main(String[] args) throws IOException { new _483().solve(); } void solve() throws IOException { try (final Scanner in = new Scanner(System.in)) { int n = in.nextInt(); A = new int[n]; for (int i = 0; i < n; i++) { A[i] = in.nextInt(); } int ans = Integer.MAX_VALUE; for (int i = 0; i < n; i++) { if (ok(i, A[i], -1, -1) && ok(i + 1, A[i] - 2 * i - 1, 1, -1)) { ans = Math.min(ans, A[i]); } if (ok(i, A[i], 1, -1) && ok(i - 1, A[i] - 2 * (n - 1 - i) - 1, -1, -1)) { ans = Math.min(ans, A[i]); } if (ok(0, A[i] - i, 1, 1)) { ans = Math.min(ans, A[i] + (n - 1 - i)); } if (ok(0, A[i] + i, 1, -1)) { ans = Math.min(ans, A[i] + i); } } System.out.println(ans); } } int[] A; boolean ok(int x, int y, int dx, int dy) { for (; x >= 0 && x < A.length; x += dx, y += dy) { if (y < A[x]) { return false; } } return true; } // for debug static void dump(Object... o) { System.err.println(Arrays.deepToString(o)); } }