#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long jawaban = 1, poin = 1;
  ;
  bool start = 0;
  while (N--) {
    int a;
    cin >> a;
    if (a == 1 && !start) {
      poin = 1;
      start = 1;
    } else if (a == 1) {
      jawaban *= poin;
      poin = 1;
    } else if (a == 0) {
      poin++;
    }
  }
  if (!start)
    cout << 0 << endl;
  else
    cout << jawaban << endl;
}
