# -*- coding: utf-8 -*- n = int(input()) x = list(map(int,input().split())) x.sort() minlen = 1000000000 for i in range(1,n): if x[i] != x[i-1]: minlen = min(minlen,abs(x[i]-x[i-1])) if minlen == 1000000000: minlen = 0 print(minlen)