#include <bits/stdc++.h>
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;
}
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout << fixed << setprecision(15);
  ;
  long long n;
  cin >> n;
  vector<long long> a(n), sum(n + 1);
  long long ans = 0;
  for (long long i = 0, i_len = (long long)(n); i < i_len; i++) {
    cin >> a[i];
    sum[i] += a[i];
    sum[i + 1] += sum[i];
    if (sum[i] == 0) ans++;
  }
  for (long long i = 0, i_len = (long long)(n); i < i_len; i++) {
    for (long long j = 0; j < i; j++) {
      if (sum[i] - sum[j] == 0) ans++;
    }
  }
  cout << ans << "\n";
}
