#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    long long a,sum;
    map<long ,long>mp;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        sum+=a;
        ++mp[sum];
    }
    long long ans=0;
    for(auto second:mp)
    {
        ans=(second*(second-1))/2;
    }
    cout<<ans<<endl;
}
