#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
unsigned gcd(unsigned a, unsigned b) {
  if (a < b) return gcd(b, a);
  unsigned r;
  while ((r = a % b)) {
    a = b;
    b = r;
  }
  return b;
}
unsigned lcm(unsigned a, unsigned b) { return a / gcd(a, b) * b; }
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
ll pow_mod(ll num, ll pow, ll mod) {
  ll prod = 1;
  num %= mod;
  while (pow > 0) {
    if (pow & 1) prod = prod * num % mod;
    num = num * num % mod;
    pow >>= 1;
  }
  return prod;
}
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
  vector<int> par;
  UnionFind(int N) : par(N) {
    for (int i = 0; i < N; i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }
  bool same(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0, i_len = (N); i < i_len; ++i) cin >> A.at(i);
  vector<ll> sum(N + 1, 0);
  for (int i = 1; i < N + 1; i++) {
    sum.at(i) = sum.at(i - 1) + A.at(i - 1);
  }
  ll ans = 0;
  for (int i = 0; i < N + 1; i++) {
    for (int j = i + 1; j < N + 1; j++) {
      ll tmp = sum.at(j) - sum.at(i);
      if (tmp == 0) ans++;
    }
  }
  cout << ans << endl;
}
