#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    int n;
    cin >> n;
    map<ll, ll> p;
    p[0] = 1;
    ll sum = 0;
    ll ans = 0;
    while (n--) {
        int temp;
        cin >> temp;
        sum += temp;
        ans += p[sum];
        p[sum]++;
    }
    cout << ans << "\n";
    return 0;
}
