#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>

using namespace std;

long long N,M,H,W;
long long A[200001];
long long B[200001] = {};
long long x[51][2] = {};
long long y[2][200] = {};
int ayasi[5] = {};
bool r[52] = {};
int check[102][102] = {};
long long result=0;
string S;
vector <long long>vl;
typedef pair<long long, long long> pl;
vector <pl> vpl;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (i == 0) {
			B[i] = A[i];
		}
		else {
			B[i] = B[i - 1] + A[i];
			if (B[i] == 0) {
				M++;
			}
		}
		vl.push_back(B[i]);

	}
	H = vl[vl.size() - 1];
	M += count(vl.begin(), vl.back(), H);
	sort(vl.begin(), vl.end());
	while (vl.size()>=2) {
		
		for (int i = 1; i < vl.size(); i++) {
			if (vl[i] != vl[0]) {
				M += i*(i - 1) / 2;
				vl.erase(vl.begin(), vl.begin() + i);
				break;
			}
			if (i == vl.size() - 1) {
				M += i*(i +1) / 2;
				vl.erase(vl.begin(), vl.end());
				break;
			}

		}
		
	}


	cout << M<<endl;
	return 0;
}
