#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, c = 200, d = 200, s = 1;
  cin >> n;
  long long int ara[n], z = 0;
  for (long long int i = 0; i < n; i++) {
    cin >> ara[i];
    if (ara[i] == 0) z++;
  }
  if (z == n) {
    cout << "0" << endl;
    return 0;
  }
  for (long long int i = 0, j = n - 1; i < n && j >= 0;) {
    if (ara[i] == 1 && c == 200) {
      c = i;
    }
    i++;
    if (ara[j] == 1 && d == 200) {
      d = j;
    }
    j--;
    if (c != 200 && d != 200) break;
  }
  long long int f = 0;
  for (long long int i = c + 1; i <= d; i++) {
    if (ara[i] == 0) {
      f++;
    } else {
      s *= (f + 1);
      f = 0;
    }
  }
  cout << s << endl;
  return 0;
}
