#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int nut;
  int p = -1;
  long long zs = 1;
  for (int i = 0; i < n; i++) {
    cin >> nut;
    if (p == -1 && nut == 1) p = i;
    if (p != -1 && nut == 1) {
      if (i - p > 1) zs *= i - p;
      p = i;
    }
  }
  if (p == -1) zs = 0;
  cout << zs << endl;
  return 0;
}
