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