SP10111 PARSUMS - Nonnegative Partial Sums
Description
You are given a sequence of _n_ numbers _a_ $ _{0} $ , …, _a_ $ _{n−1} $ . A cyclic shift by _k_ positions (0 k n−1) results in the following sequence: _a_ $ _{k} $ , _a_ $ _{k+1} $ , …, _a_ $ _{n−1} $ , _a_ $ _{0} $ , _a_ $ _{1} $ , …, _a_ $ _{k−1} $ . How many of the _n_ cyclic shifts satisfy the condition that the sum of the first _i_ numbers is greater than or equal to zero for all _i_ with 1 i n?
**Input**
Each test case consists of two lines. The first contains the number _n_ (1 n n integers _a_ $ _{0} $ , …, _a_ $ _{n−1} $ (−1000 a $ _{i} $
**Output**
For each test case, print one line with the number of cyclic shifts of the given sequence which satisfy the condition stated above.
**Sample Input**
```
3
2 2 1
3
-1 1 1
1
-1
0
```
**Sample Output**
```
3
2
0
```
- - - - - -
> _Problemsetter: Adrian Kuegel_
Input Format
N/A
Output Format
N/A