Sandwich

Time limit: 1s Memory limit: 256MB Input: Output:


Pompieru is hungry and wants to cook the famous Half-Pound Sandwich. He is given a list of NN ingredients, each one with an integer flavor-value ViV_i.

However, the Half-Pound Sandwich is very special, with some specific rules in its receipt:

  1. Ingredients are used in the order they are given. The first ingredient used must be the first one in the list, and so on.
  2. The sandwich consists of one or more levels. Each level must include one or more consecutive ingredients, and each ingredient must be part of exactly one level.
  3. The total flavor value of each level must be positive.

Task

Given the rules above, determine the maximum number of levels the sandwich can have.

Input data

On the first line of the input you are given NN, the number of ingredients.

On the second line there are NN integers, the ii-th of which represents the flavor-value of the ii-th ingredient.

Output data

On the first and only line of the output print the integer KK, the maximum number of levels the sandwich can have.

Constraints and clarifications

  • 2N4000002 \leq N \leq 400\,000
  • 109Vi109-10^9 \leq V_i \leq 10^9 for each i=0N1i=0\ldots N-1.
  • The sum of all flavour-values is positive.
# Points Constraints
1 0 Examples
2 15 N50N \leq 50, 0Vi0 \leq V_i, for each i=0N1i = 0 \ldots N - 1
3 20 N500N \leq 500
4 20 N2 000N \leq 2 \ 000
5 45 No additional constraints

Example 1

stdin

5
1 2 3 -4 5

stdout

4

Example 2

stdin

11
10 -1 1 -9 1 1 1 1 1 1 1

stdout

8

Log in or sign up to be able to send submissions!