#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int getsum(int k){
    return k*(k-1)/2;
}
long long qSum[200003], n, num;
long long n;
long long num;
int main(int argc, char const *argv[])
{
    cin>>n;
    for (int i = 1; i <= n; ++i)
    {
        cin>>num;
        qSum[i] = qSum[i-1]+num;
    }
    sort(qSum+1, qSum+n+1);
    long long sum = 0;
    long long k = 1;
    for (int i = 1; i <= n; ++i)
    {
        if(qSum[i] == 0){
            sum++;
        }
        if(qSum[i] == qSum[i+1]&&i != n){
            k++;
        } else {
            sum += k*(k-1)/2;
            k = 1;
        }
    }
    cout<<sum<<endl;
    return 0;
}