include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 5;

int n;
long long sum[N];
map <long long, int> cnt;

int main()
{
    scanf("%d", &n);
    long long ans = 0;
    cnt[0] = 1;
    for (int i = 1; i <= n; ++i) {
        int x;
        scanf("%d", &x);
        sum[i] = sum[i - 1] + x;
        ans += cnt[sum[i]];
        ++cnt[sum[i]];
    }
    printf("%lld\n", ans);
    return 0;
}