1. #include<iostream>
2. #include<algorithm>
3. using namespace std;
4. long long f(int n) {
5. 	long abc = 1;
6. 	for (int i = n; i > n - 2; --i) {
7. 		abc = abc * i;
8. 	}
9. 	abc = abc / 2;
10. 	return abc;
11. }
12. int main() {
13. 	int n;
14. 	cin >> n;
15. 	int A[200000];
16. 	for (int i = 0; i < n; i++) cin >> A[i];
17. 	long long ans = 0;
18. 	int sum[20000];
19. 	sum[0] = A[0];
20. 	for (int i = 1; i < n; i++) {
21. 		sum[i] = sum[i - 1] + A[i];
22. 	}
23. 	for (int i = 0; i < n; i++) {
24. 		if (sum[i] == 0) ans++;
25. 	}
26. 	sort(sum, sum + n);
27. 	int a = 0;
28. 	int c;
29. 	while (ptr < n) {
30. 		c = sum[a];
31. 		int e = 0;
32. 		while (a < n&&sum[a] == c) e++, a++;
33. 		ans += f(e);
34. 	}
35. 	cout << ans;
36. }
