N = int(input()) X = set(map(int, input().split())) X = list(X) X.sort() if len(X)<=1: print(0) exit() ans = X[1]-X[0] for i in range(len(X)-1): ans = min(ans, X[i+1]-X[i]) print(ans)