#include<iostream>
using namespace std;

#define ll long long
ll n,m,a[500000],b[800000000000000],ans;

int main(){
cin>>n;

for(ll i=0;i<n;i++){
cin>>a[i];
m+=a[i];
b[m+400000000000000]++;
}

for(ll i=0;i<=800000000000000;i++){
ans+=b[i]*(b[i]-1)/2;
}

cout<<ans;
return 0;
}