#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;

#define rep(i,n) for(long int i=0;i<n;i++)
#define Rep(i,n0,n) for(long int i=n0;i<n;i++)
#define Com(i,j,n) for(long int i=0;i<n-1;i++)for(long int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;

long int com(long int a){
	return (a==0) ?  0:(a*(a-1))/2;
}



long int main (){
	long int NNN;
	cin >> NNN;
	long int temp;
	long int a[NNN+1];
	a[0]=0;
	vector <long int> sum;
	rep(i,NNN){
		cin >>a[i+1];
		a[i+1] += a[i];
		sum.push_back(a[i+1]);
	}

	sort(sum.begin(),sum.end());

	temp=INF;
	long int count=1;
	long int anscount=0;

	rep(i,NNN){
		if(i==0){
			temp = sum[0];
			continue;
		}

		else if(temp==sum[i]){
			count ++;
		}

		else if(temp!=sum[i]){
			anscount += com(count);
			if(temp==0){
				anscount += count;
			}
			temp = sum[i];
			count =1;
		}

	}
	anscount += com(count);
	if(temp==0) anscount += count;


	cout << anscount << endl;

	return 0;
}
