n = int(input()) a = list(map(int, input().split())) a = sorted(a) ans = 1000000000 for i in range(n - 1): if a[i + 1] - a[i] == 0: continue ans = min(ans, a[i + 1] - a[i]) if ans == 1000000000: ans = 0 print(ans)