#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<int> A(n);
    for (int i = 0; i < n; i++) {
      cin >> A[i];
    }
    if (A == vector<int>(n)) {
      cout << 0 << '\n';
      continue;
    }
    long long ans = 1;
    for (int i = 0; i < n; i++) {
      if (A[i] == 1 && i + 1 < n) {
        vector<int>::iterator it = find(A.begin() + i + 1, A.end(), 1);
        if (it == A.end()) {
          break;
        }
        int pos = it - A.begin();
        ans *= pos - i;
        i = pos - 1;
      }
    }
    cout << ans << '\n';
  }
}
