#include <bits/stdc++.h>
using namespace std;
typedef vector<vector<int> > vii;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;
signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n);
  vector<long long> plus(n + 1, 0);
  vector<long long> minus(n + 1, 0);
  for (int i = 0; i < ((int)(n)); i++) {
    long long p;
    cin >> p;
    a[i] = p;
    if (p >= 0) {
      plus[i + 1] = plus[i] + p;
      minus[i + 1] = minus[i];
    } else {
      plus[i + 1] = plus[i];
      minus[i + 1] = minus[i] + p;
    }
  }
  long long answer = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n + 1; ++j) {
      long long cnt = (plus[j] - plus[i]) + (minus[j] - minus[i]);
      if (cnt == 0) ++answer;
    }
  }
  cout << answer << '\n';
}
