N = input() A = map(int, raw_input().split()) B = list(set(A)).sort() ans = 1 << 50 for i in range(1, len(B)): ans = min(ans, abs(B[i] - B[i - 1])) if (ans == 1 << 50): print 0 else: print ans