#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void read(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void write(T&&... args) {
  ((cout << args << " "), ...);
}
long long mod = 1000000007;
void solve() {
  int n;
  cin >> n;
  long long past = -1, ans = 1;
  bool nut = 0;
  int x;
  for (int i = 0; i < int(n); ++i) {
    cin >> x;
    if (x) {
      nut = 1;
      if (past == -1)
        past = i;
      else {
        ans *= (i - past);
        past = i;
      }
    }
  }
  cout << (nut ? ans : 0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc = 1;
  while (tc--) solve();
}
