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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> s(N+1, 0);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        s[i+1] = s[i]+A[i];
    }

    sort(s.begin(), s.end());
    s.push_back(s[n]-1);

    int cnt = 0;
    long long now = s[0], ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == now) {
            cnt++;
        } else {
            ans += cnt*(cnt-1)/2;
            cnt = 1;
            now = s[i];
        }
    }

    cout << ans << endl;
    return 0;
}