n = int(input()) x = list(map(int, input().split())) x.sort() ans = 10 ** 9 before = x[0] for num in x[1:]: d = num - before if d == 0: continue ans = min(ans, d) before = num if ans == 10 ** 9: print(0) else: print(ans)