#include <bits/stdc++.h>
using namespace std;
long long N, a[100005];
bool chk = false;
bool chkone = false;
vector<int> s;
int main() {
  long long tmp = 1, sum = 1;
  scanf("%I64d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%I64d", &a[i]);
    if (a[i] == 1) {
      chkone = true;
    }
  }
  for (int i = 0; i < N; i++) {
    if (a[i] == 1 && chk == false) {
      chk = true;
      tmp = 1;
      continue;
    }
    if (a[i] == 1) {
      sum *= tmp;
      tmp = 1;
    } else
      tmp++;
  }
  if (chkone == false) {
    printf("0\n");
    return 0;
  }
  printf("%I64d\n", sum);
  return 0;
}
