#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<long long> a(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i + 1];
  }
  for (int i = 0; i < n; i++) {
    a[i + 1] += a[i];
  }
  map<long long, int> m;
  for (auto e : a) {
    m[e]++;
  }
  long long r = 0;
  for (auto e : m) {
    if (e.second > 1) {
      r += e.second * (e.second - 1) / 2;
    }
  }
  cout << r << endl;
  return 0;
}
