n = int(input()) x = list(set(map(int,input().split()))) if(len(x) < 2): print(0) else: print(min([x[i+1] - x[i] for i in range(len(x)-1)]))