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

int main() {
    int n;
    cin >> n;
    int a[n];
    int s[n+1];
    s[0]=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        s[i+1]=s[i]+a[i];
    }
    int ans=0;
    sort(s.begin(),s.end());
    int count=1;
    for(int i=1;i<=n;i++){
        if(s[i]==s[i-1]){
            count++;
        }
        else if(s[i]!=s[i-1]){
            count=1;
        }
        if(count>=2){
            ans+=count-1;
        }
    }
    cout << ans << endl;
}