#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
vector<long long> A;
vector<long long> S;
long long solve(const int N) {
  long long res = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j + i <= N; j += 1) {
      if (S[j + i] - S[j] == 0) {
        res++;
      }
    }
  }
  return res;
}
int main(void) {
  int N;
  cin >> N;
  A.resize(N + 1);
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
  }
  S.resize(N + 1);
  S[0] = 0;
  for (int i = 1; i <= N; i++) {
    S[i] = S[i - 1] + A[i];
  }
  cout << solve(N) << endl;
  return 0;
}
