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