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