#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, c = 0, d = 1, x, f = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x == 1) f = 1;
    if (f == 1 && x != 1) c++;
    if (x == 1 && c != 0) {
      d = d * (c + 1);
      c = 0;
    }
  }
  if (f == 0)
    cout << f;
  else
    cout << d;
}
