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