#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[111] = {0};
  int n, s = 0;
  long long int sum = 1;
  int flag = 1;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (a[i] == 0 && flag == 0)
      s++;
    else if (a[i] == 1) {
      flag = 0;
      sum *= (s + 1);
      s = 0;
    }
  }
  if (flag)
    cout << 0 << endl;
  else
    cout << sum << endl;
  return 0;
}
