#include <bits/stdc++.h>
using namespace std;
void print(long long a) { cout << a << '\t' << '\n'; }
void print(long long a, long long b) { cout << a << '\t' << b << '\t' << '\n'; }
void print(long long a, long long b, long long c) {
  cout << a << '\t' << b << '\t' << c << '\n';
}
void print(long long a, long long b, long long c, long long d) {
  cout << a << '\t' << b << '\t' << c << '\t' << d << '\n';
}
void print(long long a, long long b, long long c, long long d, long long e) {
  cout << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\n';
}
void MAIN() {
  long long n;
  cin >> n;
  vector<long long> b(n), a;
  for (auto &i : b) cin >> i;
  long long i = 0;
  while (i < n and b[i] == 0) i++;
  while (i < n) a.push_back(b[i]), i++;
  if (a.size())
    while (a[a.size() - 1] == 0) a.pop_back();
  if (a.size() == 0) {
    cout << 0;
    return;
  }
  long long ans = 1;
  long long ct = 0;
  i = 0;
  n = a.size();
  while (i < n) {
    if (a[i] == 0)
      ct++;
    else
      ans *= (ct + 1), ct = 0;
    i++;
  }
  cout << ans;
}
int32_t main() {
  MAIN();
  return 0;
}
