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

#define LL long long 

map<LL ,int > mp;
LL n,a,ans;
LL sum;

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