def main(input = $stdin)
  n = input.gets.to_i
  series = []
  n.times do
    series << input.gets.to_i
  end
  lis = [0]
  series.each{|a|
    if lis.last < a
      lis << lis.last + a
    else
      i = -2
      while i >= -lis.size and lis[i] >= a
        i -= 1
      end
      if lis[i] < a and lis[i + 1] > a
        lis[i + 1] = a
      end
    end
  }
  puts lis.size - 1
end
main