n=int(input()) l=sorted(set(map(int,input().split()))) print(min(map(lambda x,y:abs(x-y),l[1:],l[:-1])) if len(l)!=1 else 0)