#include <bits/stdc++.h>
int n, a, i, cur;
long long ans;
bool flag = false;
int main() {
  scanf("%d", &n);
  for (i = 0, a = 0; i < n && a != 1; ++i) scanf("%d", &a);
  if (i == n && a == 0) flag = true;
  ans = cur = 1;
  for (; i < n; ++i) {
    scanf("%d", &a);
    if (a == 1) {
      ans *= cur;
      cur = 1;
    } else
      ++cur;
  }
  if (flag)
    printf("0\n");
  else
    printf("%I64d\n", ans);
  return 0;
}
