#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
const long long MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  vector<long long> multiplies;
  bool hasO = false;
  bool hasAt = false;
  long long mul = 0;
  for (long long i = 0; i < (int)n; i++) {
    int x;
    cin >> x;
    if (x == 1 && hasO == false) {
      hasO = true;
      hasAt = true;
      mul = 1;
    } else if (hasO == true && x == 0) {
      mul++;
    } else if (hasO = true && x == 1) {
      multiplies.push_back(mul);
      hasAt = true;
      mul = 1;
    }
  }
  if (!hasAt) {
    cout << 0 << endl;
  } else {
    long long sol = 1;
    for (long long i = 0; i < (int)multiplies.size(); i++) {
      sol *= multiplies[i];
    }
    cout << sol << endl;
  }
  return 0;
}
