#include <bits/stdc++.h>
using namespace std;
const int INF = int(1e9) + int(1e5);
const long long INFL = long long(2e18) + long long(1e10);
const unsigned int M = 1E9 + 7;
const double EPS = 1e-9;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &x) {
  return os << "(" << x.first << "," << x.second << ")";
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &x) {
  os << '[';
  if (!x.empty()) {
    std::copy(x.begin(), x.end(), std::ostream_iterator<T>(os, ","));
    os << "\b";
  }
  os << "]";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<vector<T> > &x) {
  os << '[';
  if (!x.empty()) {
    for (auto v : x) os << v << ",";
    os << "\b";
  } else
    os << "[]";
  os << "]";
  return os;
}
const int NMAX = 2E5;
int x[NMAX];
long long sx[NMAX];
long long doit(int i, int j) {
  if (i >= j) return x[i] == 0;
  int mid = (i + j) / 2;
  long long cnt = doit(i, mid);
  cnt += doit(mid + 1, j);
  map<long long, int> sumas;
  sumas[sx[mid]]++;
  for (int k = (i); k < (mid); k++) {
    sumas[sx[mid] - sx[k]]++;
  }
  long long s = 0;
  for (int k = (mid + 1); k < (j + 1); k++) {
    s -= x[k];
    auto it = sumas.find(s);
    if (it != sumas.end()) cnt += it->second;
  }
  return cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < (n); i++) cin >> x[i];
  sx[0] = x[0];
  for (int i = (1); i < (n); i++) sx[i] = sx[i - 1] + x[i];
  cout << doit(0, n - 1);
  return 0;
}
