n=int(input()) *a,=map(int,input().split()) a.sort() print(-1 if len(set(a))<2 else max(0,min([a[i]-a[i-1] for i in range(1,n) if a[i-1]