#P1526C1. Potions (Easy Version)

    ID: 2183 Type: RemoteJudge 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 5 Uploaded By: Tags>brute forcedata structuresdpgreedy*1500

Potions (Easy Version)

Description

This is the easy version of the problem. The only difference is that in this version n2000n \leq 2000. You can make hacks only if both versions of the problem are solved.

There are nn potions in a line, with potion 11 on the far left and potion nn on the far right. Each potion will increase your health by aia_i when drunk. aia_i can be negative, meaning that potion will decrease will health.

You start with 00 health and you will walk from left to right, from first potion to the last one. At each potion, you may choose to drink it or ignore it. You must ensure that your health is always non-negative.

What is the largest number of potions you can drink?

The first line contains a single integer nn (1n20001 \leq n \leq 2000) — the number of potions.

The next line contains nn integers a1a_1, a2a_2, ... ,ana_n (109ai109-10^9 \leq a_i \leq 10^9) which represent the change in health after drinking that potion.

Output a single integer, the maximum number of potions you can drink without your health becoming negative.

Input

The first line contains a single integer nn (1n20001 \leq n \leq 2000) — the number of potions.

The next line contains nn integers a1a_1, a2a_2, ... ,ana_n (109ai109-10^9 \leq a_i \leq 10^9) which represent the change in health after drinking that potion.

Output

Output a single integer, the maximum number of potions you can drink without your health becoming negative.

Sample Input 1

6
4 -4 1 -3 1 -3

Sample Output 1

5

Note

For the sample, you can drink 55 potions by taking potions 11, 33, 44, 55 and 66. It is not possible to drink all 66 potions because your health will go negative at some point