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