#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, t, i, j, k, N[1000000], sum = 1, c, v, z;
  cin >> n;
  c = 0;
  for (i = 0; i < n; i++) {
    cin >> N[i];
    if (N[i] == 1) {
      c++;
      if (c == 1) {
        k = i + 1;
      }
    }
  }
  if (c == 1) {
    cout << 1;
    return 0;
  }
  if (c == 0) {
    cout << 0;
    return 0;
  }
  for (i = k; i < n; i++) {
    if (N[i] == 1) {
      v = i + 1 - k;
      sum = sum * v;
      k = i + 1;
    }
  }
  cout << sum;
  return 0;
}
