#include <bits/stdc++.h>
using namespace std;
long long a[200003] = {0};
int n;
int main() {
  ios::sync_with_stdio(false);
  int i, t;
  long long ret = 0, sum = 0;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> t;
    a[i] = a[i - 1] + t;
  }
  sort(a + 1, a + n + 1);
  t = a[1];
  sum = 0;
  for (i = 1; i <= n; i++) {
    if (a[i] == 0) ret++;
    if (a[i] == t) {
      sum++;
    } else {
      if (sum > 1) ret += sum * (sum - 1) / 2;
      sum = 1;
      t = a[i];
    }
  }
  if (sum > 1) ret += sum * (sum - 1) / 2;
  cout << ret << endl;
  return 0;
}
