#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> total(n, 0);
  vector<int> car;
  total[0] = a[0];
  car.push_back(total[0]);
  int ans = 0;
  for (int i = 1; i < n; i++) {
    total[i] = total[i - 1] + a[i];
    car.push_back(total[i]);
    if (total[i] == 0) {
      ans++;
    }
  }
  sort(car.begin(), car.end());
  int num = 1;
  for (int i = 1; i < car.size(); i++) {
    if (car[i - 1] == car[i]) {
      num++;
      continue;
    } else {
      ans += num * (num - 1) / 2;
      num = 1;
      continue;
    }
  }
  ans += num * (num - 1) / 2;
  cout << ans << endl;
  return 0;
}
