#include <bits/stdc++.h>
using namespace std;
long long dp[100][2];
int n, arr[101];
long long rec(int idx, int f) {
  if (idx == n) {
    return 1;
  }
  if (dp[idx][f] != -1) return dp[idx][f];
  int cnt = 0, i;
  long long ret = 0;
  for (int i = idx; i < n; i++) {
    if (arr[i]) cnt++;
    if (cnt == 2) break;
    if (cnt == 0) continue;
    ret += rec(i + 1, 0);
  }
  return dp[idx][f] = ret;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int i = 0;
  while (arr[n - 1] == 0) {
    n--;
  }
  while (arr[i] == 0) i++;
  memset(dp, -1, sizeof dp);
  cout << rec(i, 0) << "\n";
  return 0;
}
