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