#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(ll a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
ll mod = 1e9 + 7;
ll Comb(ll n) {
	return n*(n - 1) / 2;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll>dp(n+1);
	for (int i = 0; i < n; i++) {
		dp[i + 1] = a[i] = 0;
	}
	dp[0] = 0;
	rep(i, n) {
		cin >> dp[i + 1];
		dp[i + 1] += dp[i];
	}
	ll ans = 0;
	Sort(dp);
	ll thiscontinue=0;
	for (int i = 1; i < n + 1; ++i) {
		if (dp[i] == dp[i - 1]) { thiscontinue++; }
		else {
			ans += Comb(thiscontinue);
			thiscontinue = 0;
		}
	}
	cout << ans << endl;

	return 0;
}
