#include <bits/stdc++.h>
int main() {
  int n;
  int a[100];
  scanf("%d", &n);
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  long long int ans = 0, count = 0;
  for (i = 0; i < n; i++) {
    if (a[i] == 1) {
      ans = 1;
      break;
    }
  }
  while (i != n) {
    if (a[i] == 0) {
      count++;
    } else {
      ans = ans * (count + 1);
      count = 0;
    }
    i++;
  }
  printf("%lld\n", ans);
  return 0;
}
