#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 1e18;
const int N = 1234;
int n;
int a[N];
int main() {
  while (scanf("%d", &n) != EOF) {
    int i, j;
    int tot = 0;
    for (i = 0; i < n; ++i) {
      int x;
      scanf("%d", &x);
      if (x == 1) a[tot++] = i;
    }
    if (!tot) {
      puts("0");
      continue;
    }
    long long ans = 1;
    for (i = 1; i < tot; ++i) {
      ans *= (a[i] - a[i - 1]);
    }
    printf("%I64d\n", ans);
  }
}
