#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> vec;
vector<long long> nextnut;
long long solve(long long idx) {
  if (idx >= n) return 0;
  if (idx == n - 1) return 1;
  long long inext = nextnut[idx + 1];
  if (inext == -1) {
    return 1;
  }
  return (inext - idx) * solve(inext);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  vec.assign(n, 0);
  nextnut.assign(n, -1);
  long long nnuts = 0;
  for (long long i = 0; i < n; i++) {
    cin >> vec[i];
    nnuts += vec[i];
  }
  if (nnuts == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (nnuts == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = i; j < n; j++) {
      if (vec[j]) {
        nextnut[i] = j;
        break;
      }
    }
  }
  cout << solve(nextnut[0]) << endl;
  return 0;
}
