//ProblemA

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemA

class Solve {
private:

	void solve() {
		int n;
		cin >> n;

		unordered_map<long long, int> m = { {0, 1} };
		long long sum = 0;

		int rst = 0;
		for (int i = 0; i < n; i++) {
			long long a;
			cin >> a;
			sum += a;

			auto it = m.find(sum);
			if (it != m.end()) {
				rst += it->second;
			}

			m[sum] += 1;
		}

		cout << rst << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}
