Tower

No attempts yetTime limit1sMemory limit128 MB

Problem

Byteasar has bought nn bricks and numbered them 11 through nn. Every brick has the same height, but their widths may differ: brick ii has width wiw_i.

He wants to stack all of the bricks into a multi-level tower under the following rules:

  • Each level is made of one or more bricks, and the width of a level equals the sum of the widths of the bricks placed on it.
  • Going from the bottom level upward, the width of any level must not exceed the width of the level directly beneath it. In other words, the level widths do not increase from bottom to top.
  • Bricks must respect their numbering: no brick may sit on a higher level than a brick with a larger identifier. Equivalently, each level is a block of consecutively numbered bricks, and the identifiers only increase as you move up.
  • Every brick must be used.

The height of the tower is its number of levels. Find the maximum height Byteasar can build.

Input

The first line contains an integer nn (1n1000001 \le n \le 100\,000), the number of bricks. The second line contains nn integers w1,w2,,wnw_1, w_2, \ldots, w_n (1wi100001 \le w_i \le 10\,000), where wiw_i is the width of brick ii.

Output

Print one integer: the maximum possible height of the tower.

Hint

Take the three bricks with widths 11, 22, 33. Put bricks 11 and 22 on the bottom level, giving it width 1+2=31 + 2 = 3, and put brick 33 on the top level, giving it width 33. Since 33 does not exceed 33, this tower is valid and has height 22.