#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];
  map<long long, int> m;
  m[0] = 1;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
    m[sum]++;
  }
  long long ret = 0;
  for (auto& x : m) {
    ret += x.second * (x.second - 1) / 2;
  }
  cout << ret << endl;
  return 0;
}
