#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, mat[100], ones = 0, oo = 0, zz = 0;
  long long ans = 1, ans1;
  cin >> p;
  for (int i = 0; i < p; i++) {
    cin >> mat[i];
    if (mat[i] == 1) ones++;
  }
  if (ones == 1) {
    cout << 1;
    return 0;
  }
  if (ones == 0) {
    cout << 0;
    return 0;
  }
  for (int i = 0; i < p; i++) {
    if (mat[i] == 1) {
      oo = 1;
      ones--;
      ans1 = zz + 1;
      ans = ans * ans1;
      zz = 0;
    } else if (oo == 1 && ones > 0)
      zz++;
  }
  cout << ans;
  return 0;
}
