#include <bits/stdc++.h>
using namespace std;
int n, a[100000], sum[100000];
int main(void) {
  int kosu = 0;
  bool renz = false;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum[i] += a[i];
    if (i > 0) sum[i] += sum[i - 1];
  }
  sort(sum, sum + n);
  int tmpnum = 0, tmpsum = 0;
  for (int k = 0; k < n; k++) {
    renz = false;
    if (sum[k] == 0 && renz == false) renz = true;
    if (k > 0 && sum[k] == sum[k - 1]) {
      renz = true;
    }
    if (renz) {
      tmpnum++;
      tmpsum = max(1, tmpsum) * tmpnum;
    } else {
      kosu += tmpsum;
      tmpnum = 0;
      tmpsum = 0;
    }
  }
  kosu += tmpsum;
  cout << kosu << "\n";
  return 0;
}
