import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) #処理内容 def main(): N = int(input()) X = list(sorted(getlist())) if N == 1: print(0) ans = INF for i in range(N - 1): if X[i + 1] != X[i]: ans = min(ans, X[i + 1] - X[i]) if ans != INF: print(ans) else: print(0) if __name__ == '__main__': main()