#include <bits/stdc++.h>
using namespace std;
long long n, i, j, m, k, x, a[100001];
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  while (!a[j]) j++;
  if (j > n) m = 1;
  x = k = 1 - m;
  for (i = j; i <= n; i++)
    if (a[i] == 1) {
      k *= x;
      x = 1;
    } else
      x++;
  cout << k << endl;
}
