#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int64_t> s(n + 1);
  s.at(0) = 0;
  int64_t a;
  for (size_t i = 0; i < n; i++) {
    cin >> a;
    s.at(i + 1) = s.at(i) + a;
  }
  sort(s.begin(), s.end());
  int64_t ans = 0;
  int now = s.at(0);
  int64_t chain = 0;
  for (size_t i = 0; i < n + 1; i++) {
    if (s.at(i) == now) {
      chain++;
    } else {
      now = s.at(i);
      ans += chain * (chain - 1) / 2;
      chain = 1;
    }
  }
  ans += chain * (chain - 1) / 2;
  cout << ans << endl;
}
