11805 - EECS_I2P17_FINAL_A   

Description

Given a sequence of positive integers, divide them into partitions (sequentially and greedily from left to right) so that the sum of the integers in each partition is as large as possible but no larger than 10.
All integers in the sequence are greater than 0 and no greater than 10.


[Example]

For example, if the input is
2 8 3 6 5 1 2 1 9 8 7 4 5
then the partitions are
[2, 8], [3, 6], [5, 1, 2, 1], [9], [8], [7], [4, 5]

The output is the number of partitions, which is 7 for this example.

Input

The first line of the input is an integer N indicating the length of the sequence. (0 < N < 1000)

The second line contains the sequence of N integers. All integers are larger than 0 and no greater than 10.

Output

The output is the number of partitions. There is NO newline character at the end of line.

Sample Input  Download

Sample Output  Download

Tags




Discuss