#include <bits/stdc++.h>
using namespace std;
int a[200000];
int main() {
  int n;
  cin >> n;
  int tmp = 0;
  for (int(i) = 0; (i) < (n); i++) {
    cin >> a[i];
  }
  for (int i = 1; i < n; i++) a[i] += a[i - 1];
  sort(a, a + n);
  int res = 0;
  for (int(i) = 0; (i) < (n); i++) {
    tmp = 1;
    if (a[i] == 0) res++;
    while (i < n && a[i] == a[i + 1]) {
      i++;
      tmp++;
      if (a[i] == 0) res++;
    }
    res += tmp * (tmp - 1) / 2;
  }
  cout << res << endl;
}
