#include <bits/stdc++.h>
#define ll long long

using namespace std;
map<ll, int> mp;
int n;

int main()
{
    cin >> n;
    mp[0]++;
    ll s = 0, ans = 0;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        s += x;
        ans += mp[s];
        mp[s]++;
    }
    cout << ans;
    return 0;
}
