n = int(input()) xn = list(map(int, input().split(' '))) sn = sorted(xn) df = [] mn = 10 ** 6 + 1 for i in range(1, n): v = sn[i] - sn[i - 1] if v != 0 and mn > v: mn = v if mn == 10 ** 6 + 1: print(0) else: print(mn)