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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int N = 501;
vector<int> input;
vector<int> newInput;
int n, a;

int znajdzParyZero(const vector<int>& ciag) {
	int n = ciag.size();
	bool znaleziono = false;
	int result = 0;
	for (int i = 0; i < n - 2; ++i) {
		for (int j = i + 1; j < n - 1; ++j) {
			for (int k = j + 1; k < n; ++k) {
				if (ciag[i] + ciag[j] + ciag[k] == 0) {
					result++;
				}
			}
		}
	}
	return result;
}

vector<int> generateNewSet(const vector<int>& ciąg) {
	vector<int> newSet;
	int suma = 0;

	for (int i = 0; i < ciąg.size(); ++i) {
		for (int j = i; j < ciąg.size(); ++j) {
			for (int k = i; k <= j; ++k) {
				suma += ciąg[k];
			}
			newSet.push_back(suma);
			suma = 0;
		}
	}
	return newSet;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		input.push_back(a);
	}
	newInput = generateNewSet(input);
	a = znajdzParyZero(newInput);
	cout << a;

	return 0;
}