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