N = int(input())
A = list(map(int, input().split()))
min_step = 10**9
step = 0
for i in range(N-1):
    if A[i] <= A[i+1]:
        step = A[i+1] - A[i]
        for j in range(N-1):
            if step + A[j] < A[j+1]:
                break
        else:
            min_step = min(min_step, step)
print(min_step)