#include <bits/stdc++.h>
using namespace std;
void fastscan(int &x) {
  bool neg = false;
  register int c;
  x = 0;
  c = getchar();
  if (c == '-') {
    neg = true;
    c = getchar();
  }
  for (; (c > 47 && c < 58); c = getchar()) x = (x << 1) + (x << 3) + c - 48;
  if (neg) x *= -1;
}
int main() {
  long long n;
  cin >> n;
  long long arr[n + 10];
  long long f = 0;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long cnt = 0;
  long long ans = 1, k = 0, flag = 0;
  for (long long i = 0; i < n; i++) {
    if (arr[i] == 1) {
      flag = 1;
      break;
    }
  }
  for (long long i = 0; i < n; i++) {
    if (arr[i] == 1) {
      k = i;
      break;
    }
  }
  long long l = 0;
  for (long long i = n - 1; i >= 0; i--) {
    if (arr[i] == 1) {
      l = i;
      break;
    }
  }
  for (long long i = k + 1; i <= l; i++) {
    if (arr[i] == 0)
      cnt++;
    else if (arr[i] == 1) {
      cnt++;
      ans *= cnt;
      cnt = 0;
    }
  }
  if (flag == 0)
    cout << 0 << "\n";
  else
    cout << ans << "\n";
  return 0;
}
