#include <bits/stdc++.h>
using namespace std;
int main() {
  int n{0};
  cin >> n;
  vector<int> vec(n), v;
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
    if (vec[i] == 1) v.push_back(i);
  }
  long long int prod = 1;
  for (int i = 1; i < v.size(); i++) {
    prod *= (v[i] - v[i - 1]);
  }
  if (v.size() == 0) prod = 0;
  cout << prod << endl;
  return 0;
}
