#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> v(n);
  for (long long(i) = (0); (i) < (n); ++i) {
    cin >> v[i];
  }
  for (long long(i) = (0); (i) < (n - 1); ++i) {
    v[i + 1] += v[i];
  }
  v.push_back(0);
  n++;
  sort(v.begin(), v.end());
  v.push_back(1000000000000000000LL);
  long long now = -1000000000000000;
  long long ans = 0;
  int cou = 0;
  for (long long(i) = (0); (i) < (n + 1); ++i) {
    if (now == v[i]) {
      cou++;
    } else {
      if (cou > 1) {
        ans += cou * (cou - 1) / 2;
      }
      now = v[i];
      cou = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
