f=[0]*1000001 n=int(input()) a=list(map(int,input().split())) a+=[0] a.sort() for i in range(1,n+1): f[i]=max(f[i-1],a[i]-f[i-1]) print(f[n])