T = int(input()) def func(a, n): for i in range(len(a)): a[i] += (i+1)*n for i in range(N-1): if a[i] >= a[i+1]: return False else: return True for _ in range(T): N = int(input()) A = list(map(int, input().split())) a = A[:] for i in range(N): a[i] += (i+1)*10**12 for i in range(N-1): if a[i] >= a[i+1]: print(-1) break else: left = -1 right = 10**12 while left+1 < right: mid = (left+right)//2 if not func(A[:], mid): left = mid else: right = mid print(right)