#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0;
  cin >> n;
  vector<long long> val(n);
  map<long long, int> c;
  for (int i = 0; i < n; i++) {
    scanf("%lld", &val[i]);
  }
  for (int i = 1; i < n; i++) {
    val[i] += val[i - 1];
  }
  for (int i = 0; i < n; i++) {
    c[val[i]]++;
  }
  for (auto i : c) {
    if (i.first == 0) {
      cnt += (i.second * (i.second - 1) / 2 + i.second);
    } else if (i.second > 1) {
      cnt += i.second * (i.second - 1) / 2;
    }
  }
  cout << cnt;
  return 0;
}
