#include <iostream>
#include <map>
using namespace std;

void print(map<long long, long long> mp){
    map<long long, long long>::iterator it;
    int sum=0;
    for(it=mp.begin();it!=mp.end();it++){
        sum+=*it.second*(*it.second-1)/2;
    }
    cout << sum << endl;
}

int main(){
    long long n, a, sum=0;
    cin >> n;
    map<long long, long long> mp;
    mp[sum]++;
    for(int i=1;i<=n;i++){
        cin >> a;
        sum+=a;
        mp[sum]++;
    }
    print(mp);
    return 0;
}