Description
Smart likes to use arrays. Today, he needs your help to complete a difficult task.
If for each non-empty sub-array of the array (A) (a sub-array is an array consisting of several consecutive elements selected from the value (A)), if the sum of all the elements of the sub-array is not equal to zero, it is called "Perfect Array". For example, the array ({−1,2,−3}) is "Perfect Array" because all its sub-arrays ({−1}), ({− 1, 2}) , ({− 1, 2, -3}), ({2}), ({2, -3}), and the sum of the elements of ({-3}) are all non-zero. However, the array ({−1, 2, −1, −3}) is not "Perfect Array" because the elements of its subarray ({−1, 2, −1}) The sum is equal to 0.
Your task is to help Smart calculate the number of "Perfect Array" in the non-empty sub-array of (A) for a given array (A).
Format
Input
The first line contains an integer (n), which represents the length of the array (A).
The second line contains (n) integers (A_1, A_2, cdots, A_n) for the elements of the array (A).
Output
Only one line of the output contains an integer, indicating that the non-empty sub-array of the array (A) is the number of "Perfect Array".
Sample
Input
3
1 2 -3
Output
5
Sample Explanation
Sub-array ({−1}) of array ({1, 2, -3}), ({− 1, 2}), ({− 1, 2, -3}), ({2}), ({2, -3}), ({-3}) is "Perfect Array", but the sub-array ({1, 2, −3}) is not "Perfect Array".
Hint
(50\%) data: (n le 1000);
Data for (100\%): (1 le n le 2 imes 10^5), (-10^9 le A_i le 10^9).
Sample Code
Code is not available!