#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt = 0;
  int64_t ans = 0, prev = 0;
  cin >> n;
  vector<int64_t> a(n), sum(n + 1, 0);
  for (auto i = 0; i < n; i++) {
    cin >> a[i];
    sum[i + 1] = sum[i] + a[i];
  }
  sort(sum.begin(), sum.end());
  for (auto i = 0; i <= n; i++) {
    if (sum[i] == prev) {
      cnt++;
      if (i == n) ans += cnt * (cnt - 1) / 2;
    } else {
      ans += cnt * (cnt - 1) / 2;
      cnt = 1, prev = sum[i];
    }
  }
  cout << ans << endl;
  return 0;
}
