#include <bits/stdc++.h>
using namespace std;
struct node {
  int u, v, c;
  node(int u, int v, int c) : u(u), v(v), c(c) {}
  bool operator<(const node &e) const { return c > e.c; }
};
int di[] = {0, -1, 0, 1};
int dj[] = {0, 1, 1, 1};
void file() {}
int n, flag = 1, flag2 = 1;
long long cnt = 1;
int main() {
  file();
  scanf("%d", &n);
  int arr[n];
  vector<int> v;
  for (int i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    if (arr[i]) {
      v.push_back(i);
    }
  }
  if (v.size() == 1) {
    printf("%d", 1);
    return 0;
  } else if (v.size() == 0) {
    printf("%d", 0);
    return 0;
  }
  for (int i = v.size() - 1; i > 0; i--) {
    cnt *= v[i] - v[i - 1];
  }
  cout << cnt;
}
