#include <bits/stdc++.h>

using namespace std;
using ll = long long;

int n;
ll sum, ans;
map<ll, int> m;

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