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