#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,int> s;
int n;
ll ans=0;
ll sum=0;
int main()
{

    scanf("%d",&n);
    ++s[0];
    while(n--)
    {
        ll x;
        scanf("%lld",&x);
        sum+=x;
        ans+=s[sum];
        ++s[sum];
    }
    printf("%lld\n",ans);
    return 0;
}
