#include <bits/stdc++.h>
using namespace std;
long long fact(long long n) {
  if (n == 0 or n == 1)
    return 1;
  else
    return n * fact(n - 1);
}
int main(void) {
  int n, a;
  cin >> n;
  map<long long, long long> mp;
  ++mp[0];
  vector<long long> v(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    cin >> a;
    v[i + 1] = v[i] + a;
    ++mp[v[i + 1]];
  }
  int ans = 0;
  for (auto x : mp) {
    long long num = x.second;
    if (x.second >= 2) {
      ans += fact(num) / (fact(2) * fact(num - 2));
    }
  }
  cout << ans << endl;
  return 0;
}
