#include <bits/stdc++.h>
using namespace std;
const int mod = 1073741824;
const int maxn = 1000005;
int arr[maxn];
int main() {
  int n;
  cin >> n;
  int a[n];
  int ind = -1;
  bool ok = false;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 1) ok = true;
  }
  long long ans = 1LL;
  for (int i = 0; i < n; i++) {
    if (a[i] == 1 && ind != -1) {
      ans *= (i - ind);
      ind = i;
    } else if (a[i] == 1)
      ind = i;
  }
  if (!ok)
    cout << 0;
  else
    cout << ans;
  return 0;
}
