#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 << 60;
const int MAX = 510000;
const int MOD = 1000000007;
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<long long> par;
  UnionFind(long long n) : par(n, -1) {}
  void init(long long n) { par.assign(n, -1); }
  long long root(long long x) {
    if (par[x] < 0)
      return x;
    else
      return par[x] = root(par[x]);
  }
  bool issame(long long x, long long y) { return root(x) == root(y); }
  bool merge(long long x, long long y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  long long size(long long x) { return -par[root(x)]; }
};
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (long long i = 0, i_len = (N); i < i_len; ++i) cin >> a[i];
  vector<int> s(N + 1, 0);
  for (long long i = 0, i_len = (N); i < i_len; ++i) s[i + 1] = s[i] + a[i];
  map<long long, long long> nums;
  for (long long i = 0, i_len = (N + 1); i < i_len; ++i) {
    ++nums[s[i]];
  }
  long long ans = 0;
  for (auto it = nums.begin(); it != nums.end(); ++it) {
    if (it->second % 2 == 0) ans += it->second / 2;
  }
  cout << ans << endl;
}
