#include <bits/stdc++.h>
using namespace std;
bool nut[105];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> nut[i];
  bool one_found = false;
  vector<int> cont;
  int temp = 1;
  for (int i = 0; i < n; ++i) {
    if (one_found) {
      if (!nut[i])
        ++temp;
      else {
        cont.push_back(temp);
        temp = 1;
      }
    }
    if (nut[i]) one_found = true;
  }
  long long ans = 1LL;
  for (int i = 0; i < cont.size(); ++i) ans *= cont[i];
  cout << (accumulate(nut, nut + n, 0) < 1 ? 0 : ans) << '\n';
}
