#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, cnt, ans = 1, i, fl = 0;
  cin >> n;
  int ar[n];
  for (i = 0; i < n; i++) cin >> ar[i];
  for (i = 0; i < n; i++) {
    cnt = 0;
    if (ar[i] == 1) {
      fl = 1;
      cnt++;
      i++;
      while (i < n && ar[i] == 0) i++, cnt++;
      if (ar[i] == 1) ans *= cnt, i--;
    }
  }
  if (fl == 0)
    cout << 0 << endl;
  else
    cout << ans << endl;
}
