#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(a,b) for (int (a) = 0; (a) < (b); (a)++)
int main() {
    int n; cin >> n;
    int a[n]; for (int i = 0; i< n; i++) {cin >> a[i];}
    int b[n]; b[0] = a[0]; for (int i = 1; i< n; i++) b[i] = b[i-1] + a[i];
    map<int,int> cnt;
    cnt[0]++;
    for (int i = 0; i < n; i++) {
        cnt[b[i]]++;
    }
    int ans = 0;
    for (auto&& A : cnt) {
        ans += A.second * (A.second - 1) / 2;
    }
    cout << ans << endl;
}
