You are given an array of pairwise distinct integers a_1, a_2, \dots, a_n.
Count the number of pairs (l,r) (1\le l\le r\le n) where a_l+\dots+a_k=a_k+\dots+a_r and is the position of the maximum element among a_l,a_{l+1},\dots,a_{r-1},a_r.
The first line contains a single integer (1\le n\le 3\cdot 10^5) — the length of the array .
The second line contains integers a_1,a_2,\dots,a_n (-10^9\le a_i\le 10^9) — elements of the array .
It is guaranteed that all integers in the array are pairwise distinct.
Output a single integer — the amount of pairs (l,r) described in the statement.
Example 1
Example 2
In the first example, the array is a=[1,3,5,4,2]. There are pairs (l,r) which satisfy the statement:
l=1, r=4; in this case equals , because is the maximum between [1,3,5,4]; the pair l=1, r=4 holds the statement, since 1+3+5=5+4;
l=1, r=1;
l=2, r=2;
l=3, r=3;
l=4, r=4;
l=5, r=5.
( points): n\le 100;
( points): n\le 10^3;
( points): a_1<a_2<\dots<a_n;
( points): there exists (1\le i\le n), such that a_1<\dots<a_i and a_i>\dots>a_n;
( points): n\le 10^5;
( points): array consists of random integers (-10^9\le a_i\le 10^9);
( points): no additional restrictions.