#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;
  for (int i = 0, t, cnt = 0; i < n; ++i) {
    scanf("%d", &t);
    if (t == 0)
      ++cnt;
    else {
      ans *= cnt;
      if (ans == 0) ++ans;
      cnt = 1;
    }
  }
  printf("%lld", ans);
  return 0;
}
