#coding: UTF-8 import sys import re import itertools from math import log from collections import deque ### defs ### ### main ### N = int(sys.stdin.readline()) X = list(map(int,sys.stdin.readline().split())) X.sort() ans=10000000 for i in range(1,N): x = X[i]-X[i-1] if(x==0): continue ans = min(ans,x) if(ans==10000000): ans=-1 print(ans)