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