#include <bits/stdc++.h>
using namespace std;
bool prime(long long n) {
  for (long long i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) return false;
  }
  return n != 1;
}
long long gcd(long long x, long long y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
long long lcm(long long x, long long y) { return x / gcd(x, y) * y; }
long long sum[250000];
signed main() {
  long long n, ans = 0;
  cin >> n;
  sum[0] = 0;
  map<long long, long long> mp;
  mp[0]++;
  for (long long i = 1; i <= n; i++) {
    long long a;
    cin >> a;
    sum[i] = sum[i - 1] + a;
    mp[sum[i]]++;
  }
  for (auto i = mp.begin(); i != mp.end(); i++) {
    long long x = i->second;
    if (x != 1) {
      long long cnt = 1;
      for (long long i = 1; i < x; i++) {
        cnt *= i;
      }
      ans += cnt;
    }
  }
  cout << ans << endl;
  getchar();
  getchar();
  return 0;
}
