n = int(input()) a = list(set(map(int,input().split()))) ans = 100000000 for i in range(n-1): ans = min(ans,a[i+1]-a[i]) print(0 if ans == 100000000 else ans)