#include <bits/stdc++.h>
using namespace std;
int n, x, nr0, nr1;
int v[105];
long long sol;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    if (x == 0) {
      ++nr0;
    } else {
      v[++nr1] = nr0;
      nr0 = 0;
    }
  }
  sol = 1;
  for (int i = 2; i <= nr1; ++i) {
    sol *= (v[i] + 1);
  }
  if (nr1 == 0) {
    cout << 0;
    return 0;
  }
  cout << sol;
  return 0;
}
