#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a[100001], prev, i, res;
  cin >> n;
  for (i = 0; i < n; ++i) cin >> a[i];
  prev = -1;
  for (i = 0; i < n; ++i) {
    if (a[i] == 1) {
      if (prev == -1)
        res = 1;
      else
        res = res * (i - prev);
      prev = i;
    }
  }
  cout << res << endl;
  return 0;
}
