#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, arr[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  long long ans = 1;
  int le = -1;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    if (arr[i] == 1) {
      if (le == -1) {
        le = i;
      } else {
        long long t = (i - le);
        ans = ans * t;
        le = i;
      }
    } else {
      cnt++;
    }
  }
  if (cnt == n) {
    cout << 0 << '\n';
    return 0;
  }
  cout << ans << '\n';
  return 0;
}
