#include <bits/stdc++.h>
using namespace std;
long long const MOD = 1e9 + 7;
class Combination {
 private:
  long long N;
  long long mod;
  vector<long long> factorial;

 public:
  Combination(long long n, long long m) : N(n), mod(m), factorial(n + 1) {
    factorial.at(0) = 1;
    for (long long i = 1; i <= N; i++) {
      factorial.at(i) = i * factorial.at(i - 1) % mod;
    }
  }
  long long POW(long long a, long long b) {
    long long ans = 1;
    while (b > 0) {
      if (b & 1) {
        ans = ans * a % mod;
      }
      a = a * a % mod;
      b >>= 1;
    }
    return ans;
  }
  long long combin(long long n, long long k) {
    return factorial.at(n) *
           POW(factorial.at(k) * factorial.at(n - k) % mod, mod - 2) % mod;
  }
};
int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  map<long long, long long> mp;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (i == 0) {
      v.at(i) = a;
    } else {
      v.at(i) = v.at(i - 1) + a;
    }
    mp[v.at(i)]++;
  }
  Combination c((long long)n, (long long)1e9 + 7);
  auto itr = mp.begin();
  long long ans = 0;
  while (itr != mp.end()) {
    if (itr->first == 0) {
      ans += itr->second;
    }
    if (itr->second > 1) {
      ans += c.combin(itr->second, 2);
    }
    itr++;
  }
  cout << ans << endl;
  return 0;
}
