#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, A[100000 * 2];
  cin >> N;
  for (long long i = 0; i < (long long)(N); i++) cin >> A[i];
  long long res = 0;
  for (long long i = 0; i < (long long)(N); i++) {
    long long sum = 0;
    long long zeroCount = -1;
    for (long long j = i; j < (long long)(N); j++) {
      sum += A[j];
      if (A[j] == 0)
        zeroCount++;
      else
        zeroCount = 0;
      if (zeroCount != j - i && sum == 0) res++;
    }
  }
  cout << res << endl;
  return 0;
}
