#!/usr/bin/env ruby

size = nil
input = []
while line = gets
  if size == nil
    size = line
  else
    input << line.chomp!.to_i
  end
end
tmp = -100

input.each_with_index { |x, i|
  (i+1).upto(input.size-1) do |j|
    if input[j] - input[i] > tmp
      tmp = input[j]-input[i]
    end
  end
}

p tmp