#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long min(long long a, long long b) { return (a < b) ? a : b; }
long long mm(vector<long long> a, vector<long long> b) {
  if (a[1] < b[1]) return true;
  if (a[1] == b[1] && a[0] < b[0]) return true;
  return false;
}
long long gcd(long long a, long long b) {
  while (1) {
    if (a == 0) return b;
    b %= a;
    if (b == 0) return a;
    a %= b;
  }
}
int main() {
  long long n, m, i, j, t, k;
  t = 1;
  for (long long ii = 0; ii < t; ii++) {
    cin >> n;
    vector<long long> a(n);
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < n; i++)
      if (a[i] == 1) break;
    if (i == n) {
      cout << 0 << endl;
      continue;
    }
    m = 1;
    long long s = 1;
    for (i = i + 1; i < n; i++) {
      if (a[i] == 1) {
        m = (m * s);
        s = 0;
      }
      s++;
    }
    cout << m << endl;
  }
  return 0;
}
