N, *X = map(int, open(0).read().split()) X = list(set(X)) if N == 1: print(0) quit() X.sort() print(min(b - a for a, b in zip(X, X[1:])))