n = int(input()) X = sorted(list(map(int,input().split()))) ret = float('inf') if len(set(X))==1: print(-1) exit() for i in range(1, n): if X[i]!=X[i-1]: ret = min(ret, abs(X[i] - X[i-1])) print(ret)