N = int(input()) Xs = list(map(int, input().split())) Xset = list(set(Xs)) Xset.sort() if len(Xset) == 1: print(0) else: print(min(a - b for a, b in zip(Xset[1:], Xset)))