#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e6 + 10;
const int MIN = 5e3 + 10;
const int MAXI = INT_MAX;
const int MINI = -INT_MAX;
const long long MAXL = (1e17 + 10);
const long long MINL = -(1e17 + 10);
long long arr[MAX], n, ans = 1;
int main() {
  cin >> n;
  int ch = 0;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    ch += (arr[i] == 0);
  }
  if (ch == n) {
    cout << 0 << endl;
    return 0;
  }
  int c = 0;
  bool ok = false;
  for (int i = 0; i < n; i++) {
    if (!arr[i])
      c++;
    else {
      if (ok) ans *= c + 1;
      ok = true, c = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
