max = -20000000000
ri = 0
count = 0;
STDIN.each_line {|line|
  if count == 0
    count = 1
    next
  end
  
  now_value = line.to_i
  if ri == 0
    ri = now_value
    next
  end

  if max < (now_value - ri)
    max = now_value - ri
  end

  if ri > now_value
    ri = now_value
  end
}

print max, "\n"

