#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x[1005];
  while (~scanf("%d", &n)) {
    int kase = 0;
    for (int i = 0; i < n; ++i) {
      scanf("%d", &x[i]);
      if (x[i]) {
        kase = 1;
      }
    }
    if (kase == 0) {
      printf("0\n");
      continue;
    }
    int l = 0;
    for (int i = 0; i < n; ++i) {
      if (x[i] == 1) {
        l = i;
        break;
      }
    }
    long long ans = 1;
    int pos = l, cnt = 0;
    while (pos < n) {
      ++pos;
      ++cnt;
      if (x[pos] == 1) {
        ans *= cnt;
        cnt = 0;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
