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 Ai. ### Output - Print the number of subarrays. ### Constraints - 1≤n≤105. - 0≤|Ai|≤109. ### Example Input: 31-21 Output: 3