#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, array[101], count = 0;
  long long ans = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &array[i]);
  for (int i = 1; i <= n; i++) {
    if (array[i] == 1) {
      if (ans == 0) ans = 1;
      while (array[i + 1] == 0) {
        i++;
        count++;
      }
      if (array[i + 1] == 1) {
        count++;
        ans *= count;
        count = 0;
      }
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
