#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, prod = 1, count = 0, a, i;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    if (a == 1) break;
  }
  for (int j = i + 1; j < n; j++) {
    cin >> a;
    if (a == 1) {
      prod = prod * (count + 1);
      count = 0;
    } else
      count++;
  }
  if (i == n)
    cout << "0" << endl;
  else
    cout << prod << endl;
  return 0;
}
