#include <bits/stdc++.h>
using namespace std;

map<long long,long long> mp;

int main()
{
    int n;
    cin>>n;
    long long ret=0,sum=0;
    mp[0]++;
    for(int i=0;i<n;i++){
    	long long a;
    	cin>>a;
    	sum+=a;
    	ret+=mp[sum];
    	mp[sum]++;
	}
	cout<<ret<<endl;
	return 0;
}