#include <iostream>
#include<cstring>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <random>

using namespace std;

#define FOR(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) FOR(i,0,n)

int N,a[1000000000];

int func(int k){
	int count = 0;
	FOR(i,0,N+1-k){
		if(!accumulate(a+i,a+i+k,0)) count++;
	}
	return count;
}
int main(){
	int count = 0;
	cin >> N;
	FOR(i,0,N) cin >> a[i];
	FOR(k,1,N+1){
		count += func(k);
		}
	cout << count << endl;

	return 0;
}