n = int(input()) x = list(set(map(int,input().split()))) x = sorted(x) if(len(x) < 2): print(0) else: l= [x[i+1] - x[i] for i in range(len(x)-1)] min_distance=min(l) print(min_distance)