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