#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
    cin >> n;
    map<ll,ll>mp;
    mp[0]++;
    ll sum=0;
    ll ret=0;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        sum+=x;
        ret+=mp[sum];
        mp[sum]++;
    }
    printf("%lld\n",ret);
}