n = gets.to_i
r = []
n.times {
	r.push( gets.to_i )
}
profit = 0-1000000000
( r.length-1 ).downto( 0 ) { |i|
	( i-1 ).downto( 0 ) { |j|
		diff = r[i] - r[j]
		if profit < diff
			profit = diff
		end
	}
}
puts( profit )