#include <bits/stdc++.h>
using namespace std;
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cout << *it << " = " << a << '\n';
  err(++it, args...);
}
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  int arr[n];
  for (__typeof(n) i = (0) - (0 > n); i != (n) - (0 > n); i += 1 - 2 * (0 > n))
    cin >> arr[i];
  int i = 0;
  while (i < n and arr[i] != 1) i++;
  long long ans = (i < n), cnt = 0;
  i++;
  while (i < n) {
    while (i < n and arr[i] != 1) {
      cnt++;
      i++;
    }
    if (i < n) {
      i++;
      ans *= cnt + 1;
      cnt = 0;
    }
  }
  cout << ans << '\n';
  return 0;
}
