#include <iostream>
using namespace std;
long long A[200001];
long long count,N,sum,Pcount,Ncount,Zcount;
int main(){
    sum = 0;
    count = 0;
    Pcount = 0;
    Ncount = 0;
    Zcount = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] > 0){
            Pcount++;
        }else if(A[i] < 0){
            Ncount++;
        }else{
            Zcount++;
        }
    }
    if((Pcount == 0 && Zcount == 0) || (Ncount == 0 && Zcount == 0)){
        cout << 0 << endl;
    }else{
        for(int i = 0; i < N; i++){    /* 部分列の長さ */
            for(int j = 0; j < N - i; j++){ /* 部分列の始点の位置 */
                for(int k = 0; k <= i; k++){
                    sum += A[j + k];
                }
                if(sum == 0){
                    count++;
                }
                sum = 0;
            }
        }
        cout << count << endl;
    }
    return 0;
}