#include <bits/stdc++.h>
using namespace std;
int arr[103];
int main() {
  vector<long long> vt;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  long long k = 0;
  for (int i = 1; i <= n; i++) {
    if (arr[i] == 1) {
      k++;
      vt.push_back(k);
      k = 0;
    } else
      k++;
  }
  long long ans = 1LL;
  for (int i = 1; i < vt.size(); i++) ans *= vt[i];
  if (vt.size() == 0) ans = 0;
  cout << ans << endl;
  return 0;
}
