#include <bits/stdc++.h>
using namespace std;
long long cara, satu, n, i, ar[102], tmp, awal, akhir;
int main() {
  cara = 1;
  satu = 0;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ar[i];
    if (ar[i] == 1) {
      satu++;
      akhir = i;
      if (satu == 1) {
        awal = i;
      }
    }
  }
  tmp = 1;
  for (i = awal; i <= akhir; i++) {
    if (ar[i] == 0) {
      tmp++;
    } else {
      cara *= tmp;
      tmp = 1;
    }
  }
  if (satu == 0) {
    printf("0\n");
  } else {
    cout << cara << "\n";
  }
}
