#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  vector<int> v;
  for (long long i = 0; i < n; i++) {
    if (arr[i] == 1) v.push_back(i);
  }
  if (v.size() <= 1)
    cout << v.size();
  else {
    long long res = 1;
    for (int i = 1; i < v.size(); i++) {
      res = res * (v[i] - v[i - 1]);
    }
    cout << res;
  }
  return 0;
}
