#include <bits/stdc++.h>
using namespace std;
int xx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
int yy[8] = {-1, 1, 0, 0, 1, -1, -1, 1};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int n;
  cin >> n;
  bool flag = true;
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) cin >> v[i];
  long long int pos1 = -1, pos2 = -1;
  for (long long int i = 0; i < n; i++) {
    if (v[i] == 1) {
      pos1 = i;
      break;
    }
  }
  if (pos1 == -1) {
    cout << "0";
    return 0;
  }
  for (int j = n - 1; j >= 0; j--) {
    if (v[j] == 1) {
      pos2 = j;
      break;
    }
  }
  long long int c = 1, ans = 1;
  if (pos1 == pos2) {
    cout << 1 << "\n";
    return 0;
  } else {
    for (long long int i = pos1; i < pos2 + 1; i++) {
      if (v[i] == 0) {
        c++;
      } else {
        ans *= c;
        c = 1;
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
