input() s = set(map(int, input().split())) if len(s) > 1: s = list(sorted(s)) print(min([s[i] - s[i - 1] for i in range(1, len(s))])) else: print(0)