1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

vector<int> num, c;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n; cin >> n;
	for (int i=0; i<n; i++){
		int a; cin >> a;
		num.pb(a);
	}

	for (int i=0; i<n; i++){
		int last = num[i];
		c.pb(last);
		for (int j=i+1; j<n; j++){
			last += num[j];
			c.pb(last);
		}
	}
	
	n = c.size();
	int res = 0;
	for (int i=0; i<n; i++)
		for (int j=i+1; j<n; j++)
			for (int k=j+1; k<n; k++){
				if (c[i]+c[j]+c[k] == 0) res++;
			}

	cout << res << "\n";


}