N = int(input()) X = list(map(int,input().split())) X = list(set(X)) X = sorted(X) candidate = [] if len(X) == 1 : print(0) else : for i in range(len(X)-1) : a = X[i+1] - X[i] candidate.append(a) if len(candidate) >= 1 : print(min(candidate))