#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, x, y, z, sum = 1, p, last, flag = 0, dif = 0, index = 1,
                           max = 0, nut = 0;
  cin >> n;
  int arr[100005];
  int arrr[100005];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    ;
    if (arr[i] == 1) {
      nut++;
    }
  }
  if (nut <= 1) {
    cout << nut;
    return 0;
  }
  nut = 0;
  for (int i = 0; i < n; i++) {
    if (arr[i] == 1 && flag == 0) {
      flag = 1;
    } else if (arr[i] == 1 && flag && nut > 0) {
      sum *= nut + 1;
      nut = 0;
    }
    if (flag && arr[i] == 0) {
      nut += 1;
    }
  }
  cout << abs(sum) << endl;
}
