#include <bits/stdc++.h>
using namespace std;
const long long OO = 1e6;
const int o_o = 0;
int getfactorial(int n) {
  int y = 1;
  for (int i = 1; i <= n; i++) {
    y = y * i;
  }
  return y;
}
int main() {
  std::ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int p = 0;
  int arr[n], nu = 0;
  ;
  for (int i = 0; i < n; i++) {
    int r;
    cin >> r;
    arr[i] = r;
    if (r == 0) {
      p++;
    } else {
      nu++;
    }
  }
  if (p == n) {
    cout << 0 << endl;
    return 0;
  }
  int pr = -1;
  long long res = 1;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 1 && pr != -1) {
      res = res * ((i + 1) - pr);
      pr = i + 1;
    } else if (arr[i] == 1 && pr == -1) {
      pr = i + 1;
    }
  }
  cout << res << endl;
  return 0;
}
