Non-negative subarray - MarisaOJ: Marisa Online Judge

Non-negative subarray

Time limit: 1000 ms
Memory limit: 256 MB
You are given an array $A$ of $n$ integers. Count the number of subarrays with non-negative sum. ### Input - The first line contains an integer $n$. - The second line contains $n$ integers $A_i$. ### Output - Print the number of subarrays. ### Constraints - $1 \le n \le 10^5$. - $0 \le |A_i| \le 10^9$. ### Example Input: ``` 3 1 -2 1 ``` Output: ``` 3 ```