#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1e18;
const int INF = 1e9;
const long double EPS = 1e-6;
const long long MOD = 1e9 + 7;
const string filename = "";
const int testgen = 100;
const bool testrun = false;
struct prog {
  void run() {
    long long n;
    long long ans = 1;
    cin >> n;
    long long lastnum = -1;
    for (int i = 0; i < n; ++i) {
      long long cur;
      cin >> cur;
      if (cur == 1) {
        if (lastnum >= 0) {
          ans *= (i - lastnum);
        }
        lastnum = i;
      }
    }
    if (lastnum == -1)
      cout << 0;
    else
      cout << ans;
  }
};
struct gen {
  void run() {
    for (int i = 0; i < 100; ++i) {
      cout << endl;
      cout << rand() << " " << rand() << endl;
      cout << "=";
    }
  }
};
void run_file(const char *in, const char *out) {
  freopen(in, "r", stdin);
  freopen(out, "w", stdout);
  while (!cin.eof()) {
    int cl = clock();
    prog p;
    p.run();
    fprintf(stderr, "Execution time: %Lf \n",
            (long double)(clock() - cl) / CLOCKS_PER_SEC * 1000);
    cout << endl << "=" << endl;
    cout.flush();
    string s;
    do cin >> s;
    while (s != "=" && !cin.eof());
  }
  cin.clear();
  cout.clear();
}
int main() {
  cin.sync_with_stdio(false);
  cout << fixed << setprecision(10);
  if (filename.compare("")) {
    freopen((filename + ".in").c_str(), "r", stdin);
    freopen((filename + ".out").c_str(), "w", stdout);
  }
  prog p;
  p.run();
  return 0;
}
