#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b, c[200100], d[210000], e, f, g[110], h[110];
  cin >> a;
  e = 0, f = 0;
  for (int i = 0; i < a; i++) cin >> c[i];
  for (int j = 0; j < a; j++) {
    d[j] = 0;
  }
  for (int i = 0; i < a; i++) {
    d[i + 1] = d[i] + c[i];
  }
  sort(d, d + a);
  for (int i = f; i < a; i++) {
    if (d[i] == 0) {
      e++;
    }
    if (d[i] != 0 || d[i] == d[i + 1]) {
      for (int j = 1; i <= a; i++) {
        if (d[i] != d[i + j]) {
          e += (j - 1) * j / 2;
          f = i + j;
        }
      }
    }
  }
  cout << e << endl;
}
