#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, b = 0, d, flag = 0, k = 0, n = 1;
  cin >> a;
  long long int v[a];
  for (long long int c = 0; c < a; c++) {
    cin >> v[c];
  }
  for (long long int c = 0; c < a; c++) {
    if (v[c] == 1) {
      if (flag == 0) {
        flag = 1;
        k = c;
      } else {
        n *= c - k;
        k = c;
      }
    }
  }
  if (flag == 0) {
    n = 0;
  }
  cout << n;
}
