#include <bits/stdc++.h>
int main() {
  int n;
  int a[110];
  long long int ans = 1;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  int num = 0;
  int left = 110, right = 110;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1) {
      left = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == 1) {
      right = i;
      break;
    }
  }
  if (left == 110 && right == 110) {
    printf("0\n");
    return 0;
  }
  if (left == right) {
    printf("1\n");
    return 0;
  }
  for (int i = left + 1; i <= right; i++) {
    if (a[i] == 0)
      num++;
    else {
      num = num + 1;
      ans *= num;
      num = 0;
    }
  }
  printf("%I64d\n", ans);
}
