#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<long long> a(n), s(n);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i == 0)
      s[i] = a[i];
    else
      s[i] = s[i - 1] + a[i];
  }
  sort(s.begin(), s.end());
  for (int i = 0; i < n; i++) {
    if (s[i] == 0) ans++;
  }
  for (int i = 1; i < n; i++) {
    long long cnt = 1;
    while (s[i] == s[i - 1]) {
      cnt++;
      i++;
    }
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}
