#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
int a[MAXN];
int main(void) {
  int n;
  int one_num = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 1) {
      one_num++;
    }
  }
  if (one_num == 1) {
    printf("1\n");
  } else if (one_num == 0) {
    printf("0\n");
  } else {
    vector<int> o;
    bool first = false;
    int tmp = 1;
    for (int i = 0; i < n; i++) {
      if (!first) {
        if (a[i] == 0) {
          continue;
        } else {
          first = true;
        }
      } else {
        if (a[i] == 0) {
          tmp++;
        } else {
          o.push_back(tmp);
          tmp = 1;
        }
      }
    }
    int s = o.size();
    long long res = 1;
    for (int i = 0; i < s; i++) {
      res *= o[i];
    }
    printf("%lld\n", res);
  }
  return 0;
}
