#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T min(T a, T b, T c) {
  return min(min(a, b), c);
}
template <class T>
inline T min(T a, T b, T c, T d) {
  return min(min(a, b), min(c, d));
}
template <class T>
inline T max(T a, T b, T c) {
  return max(max(a, b), c);
}
template <class T>
inline T max(T a, T b, T c, T d) {
  return max(max(a, b), max(c, d));
}
const int INF = 1e9;
const long long INF_LL = 4e18;
const double pi = acos(-1.0);
int dx[] = {-1, 1, 0, 0};
int dy[] = {0, 0, -1, 1};
int n, a[111];
long long solve() {
  long long ans = 0;
  for (int i = 0; i < n; i++)
    if (a[i]) {
      ans = 1;
      for (int l = i, r = i; l < n && r < n;) {
        while (r + 1 < n && !a[r + 1]) r++;
        r++;
        if (r == n) break;
        if (r == l) break;
        ans *= (long long)(r - l);
        l = r;
      }
      return ans;
    }
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  cout << solve() << endl;
  return 0;
}
