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