#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long> A(N+1,0); 
    map<long,long> mp; mp[0]++;
    for(int i=1;i<=N;i++) cin >> A[i],A[i] += A[i-1],mp[A[i]]++;
    long ans = 0;
    for(auto p : mp) ans += p.second * (p.second-1L) / 2L;
    cout << ans << endl;
}