#include <bits/stdc++.h>
using namespace std;
long long a[100010];
long long s[100010];
int n;
void acc_sum() {
  s[0] = 0;
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + a[i - 1];
  }
}
long long sec_sum(int l, int r) {
  acc_sum();
  return s[r + 1] - s[l];
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  acc_sum();
  map<long long, int> mi;
  for (int i = 0; i < n + 1; i++) {
    mi[s[i]]++;
  }
  long long sum = 0;
  for (auto ite = mi.begin(); ite != mi.end(); ite++) {
    int t = ite->second;
    if (t >= 2) {
      sum += t * (t - 1) / 2;
    }
  }
  cout << sum << "\n";
  return 0;
}
