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