#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  bool arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  deque<bool> dq(arr, arr + n);
  while (!dq.empty() && !dq.front()) dq.pop_front();
  while (!dq.empty() && !dq.back()) dq.pop_back();
  long long ans = 1;
  for (int i = 1; i < (int)dq.size() - 1; i++) {
    if (dq[i]) continue;
    int cnt = 0;
    while (i < dq.size() - 1 && !dq[i]) ++i, ++cnt;
    ans *= cnt + 1;
  }
  if (dq.empty())
    cout << "0\n";
  else
    cout << ans << endl;
}
