n = int(input()) li = list(map(int, input().split())) li.sort() dif = [] if len(li) >= 2: for i in range(len(li) - 1): if not li[i + 1] == li[i]: dif.append(li[i + 1] - li[i]) print(min(dif)) else: print('0')