#include <bits/stdc++.h>
using namespace std;

int main()
{
    long long n;
    cin >> n;

    vector<long long> a(n);
    for (long long& x : a) cin >> x;

    vector<long long> ac(n + 1, 0);
    map<long long, long long> mp;
    mp[0]++;

    for (long long i = 0; i < n; i++) {
        ac[i + 1] = ac[i] + a[i];
        mp[ac[i + 1]]++;
    }

    long long ans = 0;
    for (long long i = 0; i < n + 1; i++) {
        ans += max(0, --mp[ac[i]]);
    }
    cout << ans << endl;

    return 0;
}
