#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, a[200000], z = 1, zz = 1, zzz = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    if (i) a[i] += a[i - 1];
  }
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    if (i) {
      if (a[i - 1]) {
        if (a[i] == a[i - 1])
          z++;
        else {
          zzz += zz / 2;
          z = 1;
          zz = 1;
        }
        zz *= z;
      } else {
        if (a[i]) {
          for (long long i = 0; i < z; i++) {
            long long x = 1, y = 1;
            for (long long j = 1; j <= i; j++) {
              x *= j;
            }
            for (long long j = z; j > z - i; j--) {
              y *= j;
            }
            zzz += y / x;
          }
          z = 1;
        } else
          z++;
      }
    }
  }
  if (a[n - 1]) {
    zzz += zz / 2;
    z = 1;
    zz = 1;
  } else {
    for (long long i = 0; i < z; i++) {
      long long x = 1, y = 1;
      for (long long j = 1; j <= i; j++) {
        x *= j;
      }
      for (long long j = z; j > z - i; j--) {
        y *= j;
      }
      zzz += y / x;
    }
  }
  cout << zzz << endl;
}
