#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] == a[i - 1])
        z++;
      else {
        zzz += zz / 2;
        z = 1;
        zz = 1;
      }
      zz *= z;
    }
  }
  cout << zzz << endl;
}
