#include <bits/stdc++.h>
using namespace std;
long long a[2 * 100000 + 5];
long long cnt = 0;
long long c(long long x) { return x * (x - 1) / 2; }
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
    if (a[i] == 0) cnt++;
  }
  sort(a + 1, a + 1 + n);
  int tmp = a[1];
  int i = 2;
  int num_tmp = 1;
  int before = i;
  while (i <= n) {
    while (a[i] == tmp) {
      num_tmp++;
      i++;
    }
    if (before == i) i++;
    before = i;
    if (num_tmp > 1) cnt += c(num_tmp);
    num_tmp = 0;
    tmp = a[i];
  }
  cout << cnt << endl;
  return 0;
}
