#include <bits/stdc++.h>
using namespace std;
int asc(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int desc(const void *a, const void *b) { return *(int *)b - *(int *)a; }
int main() {
  long long n, a, cnt = 0, ans = 0;
  bool k = false;
  cin >> n;
  vector<long long> dp(n);
  cin >> a;
  dp[0] = a;
  for (int(i) = (1); (i) < (n); ++(i)) {
    cin >> a;
    dp[i] = dp[i - 1] + a;
  }
  sort(dp.begin(), dp.end());
  for (int(i) = 0; (i) < (n - 1); ++(i)) {
    if (dp[i] == 0) {
      k = true;
    }
    if (dp[i] == dp[i + 1]) {
      cnt++;
    } else {
      if (cnt != 0) {
        if (dp[i] == 0) {
          ans += pow(2, cnt);
          cnt = 0;
        } else {
          ans += pow(2, cnt) - 1;
          cnt = 0;
        }
      }
    }
  }
  if (cnt != 0) {
    if (dp[n - 1] == 0) {
      ans += pow(2, cnt);
      cnt = 0;
    } else {
      ans += pow(2, cnt) - 1;
      cnt = 0;
    }
  }
  if (k) {
    ++ans;
  }
  cout << ans << endl;
  return 0;
}
