#include <iostream>
using namespace std;

int main(){

    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    long long int count = 0;

    int table[n][n] = {};
    for(int i=0; i<n; i++){
        table[0][i] = a[i];
        if(table[0][i] == 0){
            count ++;
        }
    }

    for(int i=1; i<n; i++){
        for(int j=0; j+i<n; j++){
            table[i][j] = table[i-1][j] + a[i+j];
            if(table[i][j] == 0){
                count ++;
            }
        }
    }

    cout <<count << endl;

}