#include <bits/stdc++.h>
using namespace std;
long long a[101], dp[101], zeroes[101];
int main() {
  long long n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  dp[0] = (a[0] == 1);
  for (int i = 1; i < n; i++)
    if (a[i] == 0)
      dp[i] = dp[i - 1];
    else {
      dp[i] += (dp[i - 1] > 0 ? dp[i - 1] : 1);
      for (int j = i - 1; j > 0 && a[j] == 0; j--) dp[i] += dp[j - 1];
    }
  cout << dp[n - 1] << endl;
  return 0;
}
