#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qui queue<int>
#define vit vector<int>
using namespace std;
int main()
{int n;cin>>n;
fo(i,0,n)cin>>a[i];
int i=0,m=0;
while(i<n){
	int s=0;s+=a[i];i++;
	while(i<n&&s!=0){
		i++;s+=a[i];if(s==0)m++;
	}
}
long long er=m*(m-1)/2;
cout<<er;
system("pause");
return 0;
}