#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  bool there_is = false;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 1) {
      there_is = true;
    }
    v.push_back(a);
  }
  while (v.size() != 0 && v[0] == 0) {
    v.erase(v.begin());
  }
  while (v.size() != 0 && v[v.size() - 1] == 0) {
    v.erase(v.begin() + (v.size() - 1));
  }
  int index = 0;
  bool ant = false;
  while (index < v.size()) {
    if (!ant && v[index] == 1) {
      ant = true;
    } else if (ant && v[index] == 1) {
      v.erase(v.begin() + index);
      index--;
    } else {
      ant = false;
    }
    index++;
  }
  long long int result = there_is ? 1 : 0;
  int count = 0;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == 0) {
      count++;
    } else {
      result *= count + 1;
      count = 0;
    }
  }
  cout << result << endl;
}
