#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, sum;
    unsigned long long ans=0;
    int A[200000];
    int table[200001];
    
    cin >> N;
    for(int i=0; i<N; i++)
        cin >> A[i];
        
    for(int i=N-1; i>=0; i--){
        sum=0;
        for(int j=i; j<N; j++){
            sum += A[j];
            if(sum==0){
                table[i] = 1 + table[j+1];
                ans += table[i];
                break;
            }
        }
    }
    
    cout << ans;
    
    return 0;
}
