#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c = 0, flag = 0;
  long long int ans = 1;
  cin >> n;
  int a[n];
  vector<int> b;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (a[i] == 0 && flag == 0) continue;
    if (a[i] == 1) flag = 1;
    if (a[i] == 1 && flag == 1) {
      b.push_back(c + 1);
      c = 0;
    } else
      c++;
  }
  for (int i = 0; i < b.size(); i++) ans *= b[i];
  if (flag == 0) ans = 0;
  cout << ans;
  return 0;
}
