#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const long long INF = 1LL << 58;
int main() {
  long long N;
  cin >> N;
  vector<long long> A;
  A.resize(N);
  long long ans = 0;
  long long sum;
  for (long long i = 0; i < N; ++i) cin >> A[i];
  for (long long i = 0; i < N - 1; ++i) {
    sum = A[i];
    for (long long j = i + 1; j < N; ++j) {
      sum += A[j];
      if (sum == 0) ++ans;
    }
  }
  cout << ans << endl;
}
