#!/usr/bin/python from itertools import izip, tee def pairwise(iterable): "s -> (s0,s1), (s1,s2), (s2,s3), ..." a, b = tee(iterable) next(b, None) return izip(a, b) N = int(raw_input()) X = map(int, raw_input().split()) srt = sorted(set(X)) difs = [y-x for x, y in pairwise(srt)] or [0] print min(difs)