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