#include <iostream>
//#define int int64_t
using namespace std;
const int A = 505, B = 126000, p0 = 31000005;
int n, a[A], b[B], m[2 * p0];
int32_t main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int ind = 0, cur, p = 20005 * n;
	for (int i = 1; i <= n; i++) {
		cur = p0;
		for (int j = i; j <= n; j++) {
			cur += a[j];
			b[ind++] = cur;
		}
	}
	long long res = 0;
	cur = 3 * p0;
	for (int i = 1; i < ind - 1; i++) {
		m[b[i - 1]]++;
		cur -= b[i];
		for (int j = i + 1; j < ind; j++)
			res += m[cur - b[j]];
		cur += b[i];
	}
	cout << res;
}
        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  | #include <iostream> //#define int int64_t using namespace std; const int A = 505, B = 126000, p0 = 31000005; int n, a[A], b[B], m[2 * p0]; int32_t main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; int ind = 0, cur, p = 20005 * n; for (int i = 1; i <= n; i++) { cur = p0; for (int j = i; j <= n; j++) { cur += a[j]; b[ind++] = cur; } } long long res = 0; cur = 3 * p0; for (int i = 1; i < ind - 1; i++) { m[b[i - 1]]++; cur -= b[i]; for (int j = i + 1; j < ind; j++) res += m[cur - b[j]]; cur += b[i]; } cout << res; }  | 
            
        
                    English