#include <bits/stdc++.h>
using namespace std;
unsigned long long ans, now, n;
int a[100500];
long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  for (unsigned long long i = 1; i <= n; i++) a[i] = read();
  ans = 1;
  for (unsigned long long i = 1; i <= n; i++)
    if (a[i] == 1) {
      if (!now)
        now = i;
      else
        ans = ans * (i - now), now = i;
    }
  if (!now) {
    puts("0");
    return 0;
  }
  printf("%lld\n", ans);
  return 0;
}
