#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int count = 0;
  vector<long long> ans;
  int k = 0;
  for (int i = 0; i < n; i++) {
    int u;
    scanf("%d", &u);
    if (count > 0 && u != 0) {
      if (k != 0)
        ans.push_back(count + 1);
      else {
        ans.push_back(1);
        k = 1;
      }
      count = 0;
    } else if (count > 0 && u == 0) {
      count++;
    } else if (u == 0) {
      count++;
    } else {
      k = 1;
    }
  }
  if (count > 0 && k != 0) {
    ans.push_back(1);
  } else if (count > 0 && k == 0) {
    ans.push_back(0);
  }
  long long ans1 = 1;
  for (int i = 0; i < ans.size(); i++) {
    ans1 = ans1 * (ans[i]);
  }
  printf("%lld\n", ans1);
  return 0;
}
