#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, ans = 1;
long long a[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long prv = -1;
  for (long long i = 1; i <= n; i++) {
    if (a[i] == 1) {
      if (prv != -1) ans *= (i - prv);
      prv = i;
    }
  }
  if (prv == -1)
    cout << 0;
  else
    cout << ans;
  return 0;
}
