#include <iostream>
#include <map>
#define maxn 200005
using namespace std;
map<long long,int> cnt;
int n;
long long ans,tmp,a;
int main(){
    cin >> n;
    cnt[0] = 1;
    for(int i = 1;i<=n;i++){
        cin >> a;
        tmp += a;
        ans += cnt[tmp];
        ++cnt[tmp];
    }
    cout << ans;
}