#include <bits/stdc++.h>
using namespace std;
int nexto[120];
int ara[120];
int main() {
  std::ios_base::sync_with_stdio(false);
  ;
  int n;
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    cin >> ara[i];
  }
  int tt = n;
  for (int i = n - 1; i >= 0; i--) {
    nexto[i] = tt;
    if (ara[i] == 1) {
      tt = i;
    }
  }
  if (tt == n) {
    cout << 0 << "\n";
    return 0;
  }
  nexto[n] = n;
  long long shuru;
  if (ara[0] == 1) {
    shuru = 0;
  } else {
    shuru = nexto[0];
  }
  long long ans = 1;
  for (;;) {
    if (shuru >= n) {
      break;
    }
    long long shesh = nexto[shuru];
    if (shesh >= n) {
      break;
    }
    ans *= (shesh - shuru);
    shuru = shesh;
  }
  cout << ans << "\n";
  return 0;
}
