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