#include <bits/stdc++.h>
using namespace std;
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, 1, 0, -1};
long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
long long expo(long long n, long long m, long long p) {
  long long r = 1;
  n = n % p;
  while (m > 0) {
    if (m % 2) r = (r * n) % p;
    n = (n * n) % p;
    m = m / 2;
  }
  return r % p;
}
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long n;
long long a[105], dp[105][3];
long long solve(long long i, long long c) {
  if (i == n) {
    return c;
  }
  if (dp[i][c] != -1) return dp[i][c];
  long long ans = 0;
  if (a[i] == 1) {
    if (c == 1) {
      ans = solve(i + 1, 1);
    } else {
      ans = solve(i + 1, 1);
    }
  } else {
    if (c == 1) {
      ans = solve(i + 1, 0) + solve(i + 1, 1);
    } else {
      ans = solve(i + 1, 0);
    }
  }
  dp[i][c] = ans;
  return ans;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  memset(dp, -1, sizeof(dp));
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  cout << solve(0, 0) << '\n';
}
