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