#include<iostream>
#include<map>
using namespace std;
long long ret,sum;
map <long long,int> mp;
int main(){
int n;
cin >> n;
mp[0]++;
for(int i=0;i<n;i++){
long long a;
cin >> a;
sum+=a;
ret+=mp[sum];
mp[sum]++;
}
cout << ret;
//system("pause");
return 0;
}