#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans;
  long long int input, po, count;
  long long int a[200005];
  cin >> n;
  vector<long long int> s(n);
  s.push_back(0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s[i + 1] = a[i] + s[i];
  }
  sort(s.begin(), s.end());
  count = 1;
  ans = 0;
  po = s.front();
  s.erase(s.begin());
  for (int i = 0; i < n; i++) {
    if (po == s.front()) {
      count++;
    } else {
      if (count > 1) ans += (count) * (count - 1) / 2;
      count = 1;
      po = s.front();
    }
    s.erase(s.begin());
  }
  if (count > 1) ans += (count) * (count - 1) / 2;
  cout << ans << endl;
  return 0;
}
