n=int(input()) x=list(map(int,input().split())) x.sort() ans = 10**12 for i in range(n-1): if x[i+1]-x[i] != 0: ans = min(ans, x[i+1]-x[i]) if ans != 10**12: print(ans) else: print(-1)