#include <iostream>
#include <algorithm>
using namespace std;
int n;
int num;
long long qSum[200001];
int getsum(int k){
    return k*(k-1)/2;
}
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, qSum+n+1);
    long long sum = 0;
    int k = 1;
    for (int i = 1; i <= n; i++)
    {
        if(qSum[i] ！= qSum[i-1]){
            sum += getsum(k);
            k = 1;
        } else {
            k++;
        }
    }
    cout<<sum+getsum(k)<<endl;
    return 0;
}