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