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

int main(){
    long N;
    cin >> N;
    deque<long> A(N);
    for(auto& i : A)cin >> i;
    A.push_front(0);
    partial_sum(begin(A), end(A), begin(A));
    unordered_map<long, long> m;
    long ans(0);
    for(const auto i : A)ans += m[i]++;
    cout << ans << endl;
    return 0;
}