#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a[101], res = 1, sum = 1, i;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) {
    if (a[i] == 1) break;
  }
  if ((i - 1) == n) {
    cout << 0;
    return 0;
  }
  for (i; i <= n; i++) {
    if (a[i] == 0)
      sum++;
    else {
      res *= sum;
      sum = 1;
    }
  }
  cout << res;
}
