#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
using namespace std;
int main() {
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> cum(n);
  cum[0] = a[0];
  for (int i = 1; i < n; i++) {
    cum[i] = cum[i - 1] + a[i];
  }
  unordered_map<int, int> count;
  for (auto v : cum) {
    if (count.find(v) == count.end()) {
      count[v] = 1;
    } else {
      count[v]++;
    }
  }
  long long result = 0;
  if (count.find(0) != count.end()) {
    result += count[0];
  }
  for (auto p : count) {
    if (p.second <= 1) continue;
    result += (long long)(p.second) * (p.second - 1) / 2;
  }
  cout << result << endl;
  return 0;
}
