#include <bits/stdc++.h>
using namespace std;
int a[101];
int main() {
  bool f = false;
  int n, counter = 1;
  long long ans = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0 && f) counter++;
    if (a[i] == 1 && !f)
      f = true, ans = 1;
    else if (a[i] == 1 && f)
      ans *= counter, counter = 1;
  }
  cout << ans;
  return 0;
}
