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