#include <iostream>
#include <map>

using namespace std;

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

    map<long long, int> mp;
    long long a, ans = 0, sum = 0;
    ++mp[0];
    for (int i = 0; i < n; ++i) {
        cin >> a;
        sum += a;
        ans += mp[sum];
        ++mp[sum];
    }
    cout << ans << endl;
}