#include <cstdio>
#include <map>
#define LL long long
using namespace std;
const int N=200005;
int n,a[N];map<LL,LL>mp;
int main()
{
	scanf("%d",&n);
	mp[0]=1;LL sum=0,ans=0;
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=(LL)a[i];ans+=mp[sum];
		mp[sum]++;
	} 
    printf("%lld",ans);
}