n = gets.chomp.to_i
data = Array.new
n.times { |i|
	data[i] = gets.chomp.to_i
}

max = -1000000000

n.times { |i|
	for j in i+1..n-1
		val = data[j] - data[i]
		if max<val
			max=val
		end
	end
}
puts max