#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, a;
  long long acum = 0, ans = 1;
  bool piece = false;
  cin >> n;
  while (n--) {
    cin >> a;
    if (a == 0) {
      acum++;
    } else {
      if (acum && piece) {
        ans *= (acum + 1);
      }
      piece = true;
      acum = 0;
    }
  }
  if (!piece) ans = 0;
  cout << ans << '\n';
}
