N = input() X = sorted(map(int, raw_input().split())) print min(X[i+1]-X[i-1] for i in xrange(N-1)) if len(X)>1 else 0