#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  vector<int> v;
  scanf("%d", &n);
  int flg = 1;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x == 1) flg = 0;
    v.push_back(x);
  }
  if (flg) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == 0)
      v[i] = 1;
    else
      break;
  }
  for (int i = v.size() - 1; i >= 0; i--) {
    if (v[i] == 0)
      v[i] = 1;
    else
      break;
  }
  unsigned long long ans = 1;
  unsigned long long last = 1;
  for (int i = 0; i < v.size();) {
    if (v[i] == 1) {
      i++;
      int cnt = 0;
      while (i < v.size() && v[i] == 0) {
        i++;
        cnt++;
      }
      ans = ans * (cnt + 1);
    }
  }
  printf("%llu\n", ans);
  return 0;
}
