#include <bits/stdc++.h>
using namespace std;
class XY {
 public:
  long long x, y;
  XY() { x = y = 0; }
  XY(long long u, long long v) {
    x = u;
    y = v;
  }
};
template <typename T1, typename T2>
void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
template <typename T1, typename T2>
long long mypow(T1 a, T2 n) {
  if (n == 0) return 1;
  if (n == 1) return a;
  if (n % 2) return a * mypow(a, n - 1);
  long long tmp = mypow(a, n / 2);
  return tmp * tmp;
}
template <typename T>
int BS(vector<T> V, int left, int right, T key) {
  int mid = (left + right) / 2;
  if (V[mid] <= key)
    left = mid;
  else
    right = mid;
  if (right - mid == 1)
    return left;
  else
    return BS(V, left, right, key);
}
long long comb(long long n, long long r) {
  long long res = 1;
  for (long long i = 0; i < r; i++) {
    res *= n - i;
    res /= i + 1;
  }
  return res;
}
template <typename T>
T euclid(T a, T b) {
  if (b == 0)
    return a;
  else
    return euclid(b, a % b);
}
void Main() {
  int N;
  cin >> N;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) cin >> A[i];
  vector<long long> C(N + 1);
  C[0] = 1;
  for (long long i = 0; i < N; i++) C[i + 1] = C[i] + A[i];
  long long res = 0;
  for (long long i = 0; i < N; i++) {
    for (long long j = i; j < N; j++) {
      if (C[j + 1] - C[i] == 0) res++;
    }
  }
  cout << res << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);
  Main();
}
