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