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