#include <bits/stdc++.h>
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int n, a[202020], d[202020];
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    d[i + 1] = d[i] + a[i];
  }
  sort(d + 1, d + n + 1);
  long long ans = 0, cnt = 0;
  for (int i = 2; i <= n; i++) {
    if (d[i - 1] == d[i]) {
      cnt++;
      ans += cnt;
    } else {
      cnt = 0;
    }
  }
  ans += cnt;
  cout << ans << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
