Andrew's favourite Krakozyabra has recenly fled away and now he's eager to bring it back!

At the moment the refugee is inside an icy cave with *n* icicles dangling from the ceiling located in integer coordinates numbered from 1 to *n*. The distance between floor and the *i*-th icicle is equal to *a*<sub class="lower-index">*i*</sub>.

Andrew is free to choose an arbitrary integer point *T* in range from 1 to *n* inclusive and at time instant 0 launch a sound wave spreading into both sides (left and right) at the speed of one point per second. Any icicle touched by the wave starts falling at the same speed (that means that in a second the distance from floor to icicle decreases by one but cannot become less that zero). While distance from icicle to floor is more than zero, it is considered passable; as soon as it becomes zero, the icicle blocks the path and prohibits passing.

Krakozyabra is initially (i.e. at time instant 0) is located at point <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/eb946338365d9781f7d2e9ec692c26702d0ae3a7.png" style="max-width: 100.0%;max-height: 100.0%;"/> and starts running in the right direction at the speed of one point per second. You can assume that events in a single second happen in the following order: first Krakozyabra changes its position, and only then the sound spreads and icicles fall; in particular, that means that if Krakozyabra is currently at point <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/888531a0e13807ef7dd73a80ad9f8310660a8f1f.png" style="max-width: 100.0%;max-height: 100.0%;"/> and the falling (i.e. already touched by the sound wave) icicle at point *i* is 1 point from the floor, then Krakozyabra will pass it and find itself at <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/032de8ef739262586ef499646cfcdea1584e7a25.png" style="max-width: 100.0%;max-height: 100.0%;"/> and only after that the icicle will finally fall and block the path.

Krakozyabra is considered entrapped if there are fallen (i.e. with *a*<sub class="lower-index">*i*</sub> = 0) icicles both to the left and to the right of its current position. Help Andrew find the minimum possible time it takes to entrap Krakozyabra by choosing the optimal value of *T* or report that this mission is impossible.
The first line contains the number of icicles *n* (2 ≤ *n* ≤ 10<sup class="upper-index">5</sup>).

The next line contains *n* space-separated numbers *a*<sub class="lower-index">*i*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">5</sup>) — the distances from floor to icicles.
In sample case one it's optimal to launch the sound wave from point 3. Then in two seconds icicles 1 and 5 will start falling, and in one more seconds they will block the paths. Krakozyabra will be located at <img align="middle" class="tex-formula" src="https://espresso.codeforces.com/36de0b98a41a7a3c26317908808c214e6d4ac3ff.png" style="max-width: 100.0%;max-height: 100.0%;"/> at that time. Note that icicle number 3 will also be fallen, so there will actually be two icicles blocking the path to the left.

In sample case two it is optimal to launch the wave from point 2 and entrap Krakozyabra in 2 seconds.

In sample case four the answer is impossible.
#https://codeforces.com/problemset/problem/955/E

n = int(input())
x = list(map(int,input().split()))
L = []
T = None
for i in range(len(x)):
	l = None
	t = None
	for j in range(len(x)):
		tj = x[j] + abs(i-j)
		if tj <= j:
			if t == None:
				t = max(tj,l)
			else:
				t = min(t,max(tj,l))
		else:
			if l == None or tj <= l:
				l = tj
	if t:
		if T == None or t < T:
			T = t
 
if not T:
	print(-1)
else:
	print(T)
 