#include <bits/stdc++.h>
using namespace std;
const long long nax = 105;
long long a[nax];
signed main() {
  long long n, cnt0 = 0, cnt1 = 0;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] == 0)
      cnt0++;
    else
      cnt1++;
  }
  if (cnt0 == n) {
    cout << 0 << endl;
    return 0;
  } else if (cnt1 == n) {
    cout << 1 << endl;
    return 0;
  }
  long long idx = 0;
  long long pdt = 1;
  for (long long i = 1; i <= n; i++) {
    if (a[i] == 1) {
      if (idx == 0)
        idx = i;
      else {
        long long temp = idx;
        pdt *= i - temp;
        idx = i;
      }
    }
  }
  cout << pdt << endl;
  return 0;
}
