n = gets.to_i
rt = [gets.to_i]
got2 = gets.to_i
for i in 2..n-2
  got1 = gets.to_i
  if(rt[-1]<got2&&got2>got1)||(rt[-1]>got2&&got2<got1)
    rt<<got2
  end
  got2 = got1
end

rt << gets.to_i 
l = rt.size
ans = rt[1]-rt[0]
for i in 2..l-1
  for j in i+1..l-1
    x = rt[i]-[j]
    ans = x if ans<x
  end
end
puts ans