#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return a % b == 0 ? b : gcd(b, a % b);
}
long long int lcm(long long int a, long long int b) {
  return (a / gcd(a, b)) * b;
}
int main() {
  long long int n, res = 0;
  cin >> n;
  vector<long long int> v(n), psum;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if (i == 0)
      psum.push_back(v[i]);
    else
      psum.push_back(psum[i - 1] + v[i]);
  }
  sort(psum.begin(), psum.end());
  for (int i = 0; i < (int)psum.size(); i++) {
    int j = i + 1;
    if (psum[i] == 0) res++;
    while (j < (int)psum.size()) {
      int x = lower_bound(psum.begin() + j, psum.end(), psum[i]) - psum.begin();
      if (psum[x] == psum[i]) res++;
      j++;
    }
  }
  cout << res;
}
