Bob loves everything sweet. His favorite chocolate bar consists of pieces, each piece may contain a nut. Bob wants to break the bar of chocolate into multiple pieces so that each part would contain exactly one nut and any break line goes between two adjacent pieces.

You are asked to calculate the number of ways he can do it. Two ways to break chocolate are considered distinct if one of them contains a break between some two adjacent pieces and the other one doesn't. 

Please note, that if Bob doesn't make any breaks, all the bar will form one piece and it still has to have exactly one nut.


-----Input-----

The first line of the input contains integer n (1 ≤ n ≤ 100) — the number of pieces in the chocolate bar.

The second line contains n integers a_{i} (0 ≤ a_{i} ≤ 1), where 0 represents a piece without the nut and 1 stands for a piece with the nut.


-----Output-----

Print the number of ways to break the chocolate into multiple parts so that each part would contain exactly one nut.


-----Examples-----
Input
3
0 1 0

Output
1

Input
5
1 0 1 0 1

Output
4



-----Note-----

In the first sample there is exactly one nut, so the number of ways equals 1 — Bob shouldn't make any breaks.

In the second sample you can break the bar in four ways:

10|10|1

1|010|1

10|1|01

1|01|01

Difficulty: EASY
Tags: Combinatorics

Starter code:

Solutions:
n = int(input())
s = input().split()
if not '1' in s:
	print(0)
else:
	s = s[s.index('1'):n - s[::-1].index('1')]
	(res, step) = (1, 0)
	for i in s:
		step += 1
		if i == '1':
			res *= step
			has_started = True
			step = 0
	print(res)


n = int(input())
a = list(map(int, input().split()))
ones = []
for i in range(n):
	if a[i] == 1:
		ones.append(i)
if len(ones) == 0:
	print(0)
elif len(ones) == 1:
	print(1)
else:
	total = 1
	for i in range(1, len(ones)):
		total *= ones[i] - ones[i - 1]
	print(total)


(n, b, v) = (int(input()), list(map(int, input().split())), [])
for i in range(n):
	if b[i] == 1:
		v.append(i)
if len(v) == 0:
	print(0)
elif len(v) == 1:
	print(1)
else:
	ans = 1
	for i in range(1, len(v)):
		ans *= v[i] - v[i - 1]
	print(ans)


n = int(input())
a = list(map(int, input().split()))
l = list([0 for i in range(n)])
j = 0
for i in range(n):
	if a[i] == 1:
		l[j] = i
		j += 1
ans = 1
if j == 0:
	print(0)
	return
for i in range(j):
	if i == 0:
		continue
	ans *= l[i] - l[i - 1]
print(ans)


a = int(input())
z = 0
i = 0
k = input().replace(' ', '')
if k.count('1') == 0:
	print(0)
else:
	z = [i for i in range(a) if k[i] == '1']
	p = 1
	for i in range(len(z) - 1):
		p *= z[i + 1] - z[i]
	print(p)


import sys
n = int(input())
a = [int(x) for x in input().split()]
s = 1
count = 0
d = -1
for i in range(n):
	if a[i] == 0:
		count += 1
	else:
		if d == -1:
			d = 1
		else:
			s *= count + 1
		count = 0
if d == -1:
	print(0)
else:
	print(s)


def main():
	n = int(input())
	prev = int(-1)
	res = int(0)
	v = input().split()
	for i in range(0, n):
		if v[i] == '1':
			if prev == -1:
				res = 1
			else:
				res *= i - prev
			prev = i
	print(res)
main()


n = int(input())
a = list(map(int, input().split()))
o = []
for i in range(n):
	if a[i] == 1:
		o.append(i)
if len(o) == 0:
	print(0)
elif len(o) == 1:
	print(1)
else:
	prod = 1
	for i in range(1, len(o)):
		prod *= o[i] - o[i - 1]
	print(prod)


_ = input()
pos_1 = []
for (i, e) in enumerate(input().split()):
	if e == '1':
		pos_1.append(i)
if not pos_1:
	print(0)
elif len(pos_1) == 1:
	print(1)
else:
	tot = 1
	for i in range(1, len(pos_1)):
		tot *= pos_1[i] - pos_1[i - 1]
	print(tot)


input()
nuts = input().replace(' ', '').replace('0', ' ').strip().split('1')
if len(nuts) == 1 and nuts[0] == '':
	print(0)
	exit(0)
mult = 1
for el in nuts:
	mult *= len(el) + 1
print(mult)


import math
l1 = int(input())
l2 = input().split()
l2 = [int(i) for i in l2]
r = 1
x = []
for i in range(l1):
	if l2[i] == 1:
		x.append(i)
if x.__len__() == 0:
	print(0)
else:
	for i in range(1, x.__len__()):
		r = r * (x[i] - x[i - 1])
	print(r)


n = int(input())
l = list(map(int, input().split()))
ans = 1
prev = -1
for i in range(n):
	if l[i] == 1 and prev == -1:
		prev = i
	elif l[i] == 1:
		ans *= i - prev
		prev = i
if prev == -1:
	print(0)
else:
	print(ans)


n = int(input())
a = [int(i) for i in input().split()]
pos = []
for i in range(n):
	if a[i] == 1:
		pos.append(i)
if len(pos) == 0:
	print(0)
else:
	prod = 1
	for i in range(len(pos) - 1):
		prod *= pos[i + 1] - pos[i]
	print(prod)


ans = 0
a = int(input())
a = input().split()
cnt = 1
for i in range(len(a)):
	if a[i] == '1':
		ans = 1
		a = a[i:]
		break
for i in range(len(a)):
	if a[i] == '0':
		cnt += 1
	else:
		ans *= cnt
		cnt = 1
print(ans)


import sys
import math
import collections
import bisect
from collections import deque as queue

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	n = int(input())
	arr = get_list()
	one = []
	for i in range(n):
		if arr[i] == 1:
			one.append(i)
	ans = 1
	if len(one) == 0:
		print(0)
		continue
	for i in range(len(one) - 1):
		gap = one[i + 1] - one[i]
		ans *= gap
	print(ans)


l = int(input())
arr = list(map(int, input().split()))
splits = 0
prev_1 = -1
for i in range(l):
	e = arr[i]
	if e == 1:
		if prev_1 == -1:
			splits = 1
			prev_1 = i
		else:
			splits *= i - prev_1
			prev_1 = i
print(splits)


n = int(input())
arr = [int(j) for j in input().split()]
pos = []
for i in range(n):
	if arr[i] == 1:
		pos.append(i)
if len(pos) == 0:
	print(0)
elif len(pos) == 1:
	print(1)
else:
	mul = 1
	for i in range(len(pos) - 1):
		mul *= pos[i + 1] - pos[i]
	print(mul)


n = int(input())
s = input()
s = s.split()
l = list()
zeroes = 0
for i in range(n):
	if s[i] == '0':
		zeroes += 1
	elif zeroes == 0:
		continue
	else:
		l.append(zeroes)
		zeroes = 0
ans = 1
for i in l:
	ans *= i + 1
if s.count('1') == 0:
	ans = 0
elif s.count('0') == 0:
	ans = 1
elif s[0] != '1':
	ans //= l[0] + 1
print(ans)


import math
n = int(input())
l = list(map(int, input().split()))
zero = 1
ans = 1
start = 0
for i in range(n):
	if l[i] == 1:
		start = i
		break
end = 0
if l.count(1) == 0:
	print(0)
else:
	for i in range(n - 1, -1, -1):
		if l[i] == 1:
			end = i
			break
	for i in range(start, end + 1):
		if l[i] == 0:
			zero += 1
		else:
			ans *= zero
			zero = 1
	print(ans)


N = int(input())
A = ''.join(input().split())
A = A.split('1')
if len(A) == 1:
	print(0)
	exit(0)
A = A[1:-1]
answer = 1
for x in A:
	answer *= len(x) + 1
print(answer)


__author__ = 'Admin'
n = int(input())
m = list(map(int, input().split()))
t = 1
ans = 1
while m[0] == 0:
	if len(m) == 1 and m[0] == 0:
		ans = 0
		break
	else:
		m.pop(0)
while m[len(m) - 1] == 0:
	m.pop(len(m) - 1)
	if len(m) == 0:
		ans = 0
		break
for i in range(len(m)):
	for j in range(len(m)):
		if len(m) > 1 + j and m[1 + j] == 0:
			t += 1
		else:
			m = m[j + 1:]
			break
	ans *= t
	t = 1
print(ans)


(n, a, last, ans) = (input(), list(map(int, input().split())), -1, 1)
if not 1 in a.copy():
	print(0)
	exit(0)
for s in a:
	if s:
		if ~last:
			ans *= last
		last = 1
	elif ~last:
		last += 1
print(ans)


def f(array):
	aux = []
	a = 0
	total = 1
	zeros = 0
	primeiro = False
	for e in array:
		if e == '1' and primeiro == False:
			a += 1
			primeiro = True
			continue
		if primeiro:
			if e == '0':
				zeros += 1
			if e == '1':
				aux.append(zeros + 1)
				zeros = 0
	if a == 0:
		return 0
	for e in aux:
		total *= e
	return total
n = int(input())
array = input().split()
print(f(array))


n = int(input())
l = [int(i) for i in input().split()]
f = -1
ans = 0
for i in range(n):
	if l[i] == 1:
		if f == -1:
			ans = 1
		else:
			ans *= i - f
		f = i
print(ans)


n = int(input())
p = input().rstrip().split(' ')
zero = 0
one = 0
C = -1
for i in range(0, len(p)):
	if int(p[i]) == 0:
		zero += 1
	else:
		C = i
		break
if C != -1:
	back_zero = zero
	zero = 0
	l = []
	for i in range(C + 1, len(p)):
		if int(p[i]) == 0:
			zero += 1
		else:
			l.append(zero + 1)
			zero = 0
	end_zero = zero
	H = 1
	if 1:
		for i in range(0, len(l)):
			H = H * l[i]
		print(H)
else:
	print(0)


import math, sys, re, itertools, pprint
(ri, rai) = (lambda : int(input()), lambda : list(map(int, input().split())))
n = ri()
s = ''.join(input().split()).strip('0')
a = re.findall('0+', s)
res = 1
for i in a:
	res *= len(i) + 1
print(res if '1' in s else 0)


import sys
n = int(input())
a = [int(i) for i in input().split()]
if not 1 in a:
	print(0)
	sys.exit()
i = 0
while i < n and a[i] == 0:
	i += 1
j = n - 1
while j >= 0 and a[j] == 0:
	j -= 1
overall = 1
current = 1
while i < j:
	while i < j and a[i] == 0:
		current += 1
		i += 1
	overall *= current
	while i < j and a[i] == 1:
		i += 1
	current = 1
print(overall)


n = int(input())
arr = list(map(int, input().split()))
prev = -1
res = 0
for i in range(0, n):
	if arr[i] == 1:
		if prev == -1:
			res = 1
		else:
			res *= i - prev
		prev = i
print(res)


n = int(input())
l = input().split(' ')
first = 0
while first <= n - 1 and l[first] == '0':
	first += 1
if first == n:
	print(0)
else:
	last = n - 1
	while last >= 0 and l[last] == '0':
		last -= 1
	count = 0
	divide = []
	for i in range(first, last + 1):
		if l[i] == '0':
			count += 1
		else:
			divide.append(count + 1)
			count = 0
	ans = 1
	for i in range(len(divide)):
		ans *= divide[i]
	print(ans)


n = int(input())
l = list(map(int, input().split()))
ans = 1
p = -1
for i in range(len(l)):
	if l[i] == 1:
		if p == -1:
			p = i
			continue
		if i - p:
			ans *= i - p
		p = i
if p != -1:
	print(ans)
else:
	print(0)


n = int(input())
l = list(map(int, input().rstrip().split(' ')))
al_ones = []
for i in range(n):
	if l[i] == 1:
		al_ones.append(i)
if al_ones:
	t = 1
	for i in range(1, len(al_ones)):
		d = al_ones[i] - al_ones[i - 1] - 1
		if d > 0:
			t = t * (d + 1)
	print(t)
else:
	print(0)


n = int(input())
arr = list(map(int, input().split()))
pos = -1
cnt = 0
for i in range(n):
	if arr[i] == 1:
		if pos == -1:
			cnt = 1
		else:
			cnt *= i - pos
		pos = i
if pos == -1:
	print('0')
else:
	print(cnt)


n = int(input())
a = list(map(int, input().split()))
while a[0] == 0:
	a = a[1:]
	if a == []:
		print(0)
		exit(0)
while a[-1] == 0:
	a = a[:-1]
ans = 1
k = 1
for i in a:
	if i:
		ans *= k
		k = 1
	else:
		k += 1
print(ans)


n = int(input(''))
a = input('').split(' ')
i = 0
b = ''
while i < n:
	b += a[i]
	i += 1
b = b.split('1')
i = 1
j = 1
n = len(b) - 1
if n != 0:
	j = 1
	while i < n:
		j *= len(b[i]) + 1
		i += 1
else:
	j = 0
print(j)


n = int(input())
a = list(map(int, input().split()))
start = -1
end = -1
for i in range(n):
	if start == -1 and a[i] == 1:
		start = i
	if end == -1 and a[n - (i + 1)] == 1:
		end = n - (i + 1)
if start == -1:
	print(0)
	exit(0)
vals = []
zeroes = 0
for i in range(start, end + 1):
	if a[i] == 1:
		if zeroes:
			vals.append(zeroes + 1)
		zeroes = 0
	else:
		zeroes += 1
prod = 1
for i in vals:
	prod *= i
print(prod)


input()
c = ''.join(input().split()).strip('0')
print(eval('*'.join([str(len(t) + 1) for t in c.strip('1').split('1')])) if c.count('1') else 0)


n = int(input())
arr = list(map(int, input().split()))
if arr.count(1) == 1:
	print(1)
elif arr.count(1) == 0:
	print(0)
else:
	start = 0
	ans = 1
	count = 1
	good = False
	while start < n:
		if arr[start] == 1:
			good = True
			ans *= count
		if good:
			if arr[start] == 0:
				count += 1
			else:
				count = 1
		start += 1
	print(ans)


o = int(input())
c = input().replace(' ', '').strip('0').split('1')
n = 1
if len(c) == 1:
	print(0)
	exit()
for i in c:
	n *= len(i) + 1
print(n)


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
a = input()
if a.count('1') == 0:
	print(0)
	exit()
a = a.replace(' ', '')
a = a.replace('0', ' ')
a = a.strip()
a = a.replace(' ', '0')
ans = []
count = 0
for i in a:
	if i == '1':
		if count > 0:
			ans.append(count)
		count = 0
	else:
		count += 1
answer = 1
if len(ans) == 0:
	print(answer)
else:
	for i in ans:
		answer *= i + 1
	print(answer)


from itertools import groupby
N = int(input())
A = list(map(int, input().split()))
groups = groupby(A)
keys = []
cnts = []
for (k, vals) in groups:
	keys.append(k)
	cnts.append(len(list(vals)))
ngroups = len(keys)
if ngroups == 1:
	if keys[0] == 0:
		print(0)
		exit()
ans = 1
for i in range(ngroups):
	if keys[i] == 0:
		if i - 1 >= 0 and i + 1 < ngroups:
			ans *= cnts[i] + 1
print(ans)


n = int(input())
bar = input().replace(' ', '').split('1')
if len(bar) == 1:
	print(0)
	exit()
o = 1
for i in range(1, len(bar) - 1):
	o *= len(bar[i]) + 1
print(o)


import math
import bisect
import sys
from collections import OrderedDict
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
N = inp()
A = inlt()
i = 0
while i < N and A[i] != 1:
	i += 1
if i == N:
	print(0)
else:
	prev = i
	out = 1
	for j in range(i + 1, N):
		if A[j] == 1:
			out *= j - prev
			prev = j
	print(out)


n = int(input())
arr = list(map(int, input().split()))
if arr.count(1) == 1:
	print(1)
	exit()
elif arr.count(1) == 0:
	print(0)
	exit()
t = -1
res = 1
for i in range(n):
	if arr[i] == 1 and t == -1:
		res = 1
		t = i
	elif arr[i] == 1:
		res *= i - t
		t = i
print(res)


input()
choc = ''.join(input().split()).strip('0')
if choc.count('1') <= 1:
	print(choc.count('1'))
else:
	ans = 1
	for t in choc.strip('1').split('1'):
		ans *= len(t) + 1
	print(ans)


n = int(input())
l = list(map(int, input().split()))

def lmul(n):
	s = 1
	for x in n:
		s *= x
	return s
indices = [i + 1 for (i, x) in enumerate(l) if x == 1]
if len(indices) == 0:
	print(0)
elif len(indices) == 1:
	print(1)
else:
	p = [t - s for (s, t) in zip(indices, indices[1:])]
	print(lmul(p))


n = input()
a = 1
prev = -1
for (i, v) in enumerate(map(int, input().split())):
	if v == 1:
		if prev != -1:
			a *= i - prev
		prev = i
if prev == -1:
	print(0)
else:
	print(a)


n = int(input())
x = list(map(int, input().split()))
st = ''
for i in x:
	st += str(i)
ans = st.split('1')
answer = 1
for i in ans:
	answer = answer * (len(i) + 1)
if st[0] == '0':
	answer = answer // (len(ans[0]) + 1)
if st[-1] == '0':
	answer = answer // (len(ans[-1]) + 1)
print(answer)


import itertools as it
import operator as op
input()
s = input()
if s.count('1') == 0:
	print(0)
else:
	s = ''.join(s.split(' ')).strip('0').split('1')
	print(list(it.accumulate([len(i) + 1 for i in s], op.mul))[-1])


n = int(input())
l = list(map(int, input().split()))
ans = []
if l.count(1) == 0:
	print('0')
	exit()
d = []
for i in range(n):
	if l[i] == 1:
		d.append(i)
for i in range(1, len(d)):
	x = d[i] - d[i - 1]
	ans.append(x)
res = 1
for i in ans:
	res *= i
print(res)


n = int(input())
choc = input().split()
last = choc[0]
result = int(last)
current = 1
for i in range(1, n):
	part = choc[i]
	if part == '0':
		current += 1
	elif last != '1':
		if result == 0:
			result = 1
		else:
			result *= current
		current = 1
	last = part
print(result)


n = int(input())
a = list(map(int, input().strip().split()))
if list(set(a)) == [0]:
	print(0)
else:
	b = []
	for i in range(n):
		if a[i] == 1:
			b.append(i)
	c = []
	for j in range(len(b) - 1):
		c.append(b[j + 1] - b[j])
	d = 1
	for k in range(len(c)):
		d = d * c[k]
	print(d)


n = int(input())
a = list(map(int, input().split()))
if a.count(1) == 0:
	print(0)
elif a.count(1) == 1:
	print(1)
else:
	ans = 1
	cnt = 0
	for i in range(1, n):
		if a[i] == 0:
			if a[i - 1] == 1:
				cnt = 1
			elif cnt > 0:
				cnt += 1
		else:
			ans *= cnt + 1
			cnt = 0
	print(ans)


a = int(input())
b = list(map(int, input().split()))
if 1 not in b:
	print(0)
else:
	c = b.index(1)
	d = 1
	for i in range(c + 1, a):
		if b[i] == 1:
			d *= i - c
			c = i
	print(d)


n = int(input())
s = ''
p = list(map(int, input().split()))
if p.count(1) == 0:
	c = 0
elif p.count(1) == 1:
	c = 1
else:
	for i in range(n):
		s += str(p[i])
	l = s.split('1')
	c = 1
	for i in range(1, len(l) - 1):
		c *= len(l[i]) + 1
print(c)


n = int(input())
l = [int(i) for i in input().split()]
prev = -1
result = 0
for i in range(n):
	if l[i] == 1:
		if prev == -1:
			result = 1
		else:
			result *= i - prev
		prev = i
print(result)


n = int(input())
a = [int(x) for x in input().split()]
i = n - 1
while i >= 0 and a[i] == 0:
	i -= 1
n = i + 1
count = 0
if not n == 0:
	i = 0
	while i < n and a[i] == 0:
		i += 1
	count = 1
	while i < n:
		j = i + 1
		while j < n and a[j] == 0:
			j = j + 1
		count *= j - i
		i = j
print(count)


import sys
n = int(input())
an = list(map(int, sys.stdin.readline().split()))
ans = 0
pre = 0
for i in range(n):
	if an[i] is 1:
		if ans is 0:
			ans = 1
		else:
			ans *= i - pre
		pre = i
print(ans)


def solve():
	numbers = int(input())
	lst = [int(x) for x in input().split(' ')]
	add = sum
	if add(lst) <= 1:
		print(add(lst))
		return
	elif add(lst) == len(lst):
		print(1)
		return
	left_index = lst.index(1)
	right_index = left_index
	for i in range(left_index, len(lst)):
		if lst[i] == 1:
			right_index = i
			break
	total = 1
	while right_index < len(lst):
		if lst[right_index] == 1:
			delta = right_index - left_index
			total *= max(1, delta)
			left_index = right_index
		right_index += 1
	print(total)
solve()


n = int(input())
nuts = list(map(int, input().split()))
label = 0
if nuts.count(1):
	ans = 1
else:
	ans = 0
for i in nuts:
	if i == 1:
		if label:
			ans *= cnt
		label = 1
		cnt = 0
	if label:
		cnt += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
num = -1
ans = 1
for i in range(0, len(a)):
	if a[i] == 1:
		if num != -1:
			ans *= i - num
		num = i
if a.count(1) == 0:
	ans = 0
print(ans)


n = int(input())
a = [int(s) for s in input().split()]
b = [0] * n
nb = 0
k = 0
while k < n and a[k] < 1:
	k += 1
if k > n - 1:
	print(0)
else:
	q = 1
	for i in range(k + 1, n):
		if a[i] == 1:
			nb += 1
			q += 1
		else:
			b[nb] += 1
	sum = 1
	for i in range(q - 1):
		sum *= b[i] + 1
	print(sum)


def main():
	input()
	j = res = 0
	for (i, c) in enumerate(input()[::2]):
		if c == '1':
			if res:
				res *= i - j
			else:
				res = 1
			j = i
	print(res)
main()


n = int(input())
chocolate = list(map(int, input().split()))
prev = 0
parts = 1
start = False
count = 0
nut = False
for c in chocolate:
	if c == 0:
		if start:
			count += 1
		prev = 0
	else:
		start = True
		nut = True
		if prev != 1:
			parts *= count + 1
			count = 0
		prev = 1
if nut:
	print(parts)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
try:
	start = a.index(1)
except ValueError:
	start = -1
try:
	end = n - 1 - a[::-1].index(1)
except ValueError:
	end = -1
if start == -1:
	print(0)
	exit(0)
vals = []
zeroes = 0
for i in range(start, end + 1):
	if a[i] == 1:
		if zeroes:
			vals.append(zeroes + 1)
		zeroes = 0
	else:
		zeroes += 1
prod = 1
for i in vals:
	prod *= i
print(prod)


import sys
from collections import defaultdict
from functools import lru_cache

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))
euc_dist = lambda x1, y1, x2, y2: ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5

def main(arr):
	if 1 not in arr:
		print(0)
		return
	arr = ''.join((str(d) for d in arr))
	arr = arr.split('1')
	if len(arr) <= 2:
		print(1)
		return
	s = 1
	arr = arr[1:-1]
	for c in arr:
		s *= len(c) + 1
	print(s)
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		continue
	else:
		arr = lmi(line)
main(arr)


n = int(input())
a = list(map(int, input().split()))
ans = 0
prev = -1
for i in range(n):
	if a[i] == 1:
		if prev == -1:
			ans = 1
		else:
			ans *= i - prev
		prev = i
print(ans)


n = int(input())
a = input().split()
(ans, pre) = (1, -1)
for i in range(n):
	if int(a[i]) == 1:
		if pre != -1:
			ans *= i - pre
		pre = i
print(ans if pre != -1 else 0)


from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
if 1 not in c:
	print(0)
elif c[1] == 1:
	print(1)
else:
	c = 1
	pi = a.index(1)
	for i in range(pi, n):
		if i > pi and a[i] == 1:
			c *= i - pi
			pi = i
	print(c)


n = int(input())
arr = list(map(int, input().split()))
ans = []
for i in range(n):
	if arr[i] == 1:
		ans.append(i + 1)
roliing_sub = []
for i in range(1, len(ans)):
	roliing_sub.append(ans[i] - ans[i - 1])
ans = 1
for i in roliing_sub:
	ans *= i
if 1 not in arr:
	print(0)
else:
	print(ans)


n = int(input())
s = list(map(int, input().split()))
if s.count(1) == 0:
	print('0')
else:
	ans = 1
	sp = 0
	f = True
	for i in s:
		if i == 0:
			sp += 1
		elif f:
			f = False
			sp = 1
		else:
			ans *= sp
			sp = 1
	print(ans)


import sys
n = int(input())
a = [int(x) for x in input().split()]
s = sum(a)
if s <= 1:
	print(s)
	sys.exit()
ibe = 0
while a[ibe] == 0:
	ibe += 1
ien = n - 1
while a[ien] == 0:
	ien -= 1

def cnt(start):
	if start == ien:
		return 1
	inext = start + 1
	while a[inext] == 0:
		inext += 1
	return (inext - start) * cnt(inext)
print(cnt(ibe))


from math import *
n = int(input())
s = ''.join(input().split())
i = 0
if len(s) == s.count('0'):
	print(0)
	quit()
while s[i] != '1':
	s = s[i + 1:]
cnt = 1
res = 1
for i in range(len(s)):
	if s[i] == '1':
		res *= cnt
		cnt = 1
	if s[i] == '0':
		cnt += 1
print(res)


import collections
n = int(input())
a = [int(i) for i in input().split()]
d = collections.Counter(a)
if d[1] == 0:
	print(0)
elif d[1] == 1:
	print(1)
else:
	flag = -1
	ans = 1
	for i in range(0, n):
		if a[i] == 1:
			if flag == -1:
				flag = i
			else:
				ans = ans * (i - flag)
				flag = i
	print(ans)


x = int(input())
v = ''.join(input().split()).strip('0')
if '1' not in v:
	print(0)
	exit(0)
z = []
zeroes = 0
for i in v:
	if i == '0':
		zeroes += 1
	else:
		z.append(zeroes)
		zeroes = 0
x = 1
for i in z:
	x *= i + 1
print(x)


n = int(input())
a = list(map(int, input().split()))
while len(a) > 0 and a[-1] == 0:
	a.pop()
n = len(a)
if n == 0:
	print(0)
	exit(0)
i = 0
ans = 1
while i < n and a[i] == 0:
	i += 1
while i < n:
	j = i + 1
	while j < n and a[j] == 0:
		j += 1
	ans *= j - i
	i = j
print(ans)


n = int(input())
a = list(map(int, input().split()))
if len(a) == a.count(0):
	print(0)
else:
	r = 1
	t = []
	for (i, b) in enumerate(a):
		if b == 1:
			t += [i]
	for i in range(len(t) - 1):
		r *= t[i + 1] - t[i]
	print(r)


from itertools import permutations
from collections import defaultdict
from math import *
import os
import sys
from io import BytesIO, IOBase
from heapq import nlargest
from bisect import *
import copy
import itertools
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
n = int(input())
arr = list(map(int, input().split()))
count = 0
for i in range(n):
	if arr[i] == 1:
		count += 1
if count <= 1:
	print(count)
else:
	startProcess = False
	count = 1
	ans = 1
	for i in range(n):
		if arr[i] == 1:
			if startProcess:
				ans *= count
			startProcess = True
			count = 1
		else:
			count += 1
	print(ans)


n = int(input())
s = input()
x = 0
while x <= len(s) and s[x] == '0':
	x += 2
ans = int(x <= len(s))
zeros = 1
for i in range(x, len(s), 2):
	if s[i] == '1':
		ans *= zeros
		zeros = 1
	else:
		zeros += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
adj_cell = list()
total_adj = 0
for i in range(n):
	if a[i] == 0:
		continue
	adj = 0
	for j in range(i - 1, -1, -1):
		if a[j] == 1:
			break
		adj += 1
		if j == 0:
			adj = 0
	adj_cell.append(adj + 1)
ret = int(1 in a)
for val in adj_cell:
	ret *= val
print(ret)


inp = lambda : map(int, input().split())
n = input()
a = list(inp())
res = 0
prev = -1
for i in range(len(a)):
	if a[i] == 1:
		if prev == -1:
			res = 1
		else:
			res *= i - prev
		prev = i
print(res)


num = int(input())
choco = [int(x) for x in input().split()]
dp = [0 for i in range(num)]
dp[0] = choco[0]
for i in range(1, num):
	if choco[i] == 0:
		dp[i] = dp[i - 1]
	else:
		zeros = 0
		k = i - 1
		while k >= 0 and choco[k] == 0:
			zeros += 1
			k -= 1
		if zeros == i:
			dp[i] = 1
		else:
			result = 0
			for j in range(1, zeros + 2):
				result += dp[i - j]
			dp[i] = result
print(dp[num - 1])


n = int(input())
pieces = list(map(int, input().split()))
ret = 1
i = 0
if pieces.count(1) == 0:
	print(0)
	quit()
while i < n and pieces[i] == 0:
	i += 1
i += 1
while i < n:
	temp = 1
	while i < n and pieces[i] == 0:
		i += 1
		temp += 1
	if i < n:
		ret *= temp
	i += 1
print(ret)


n = int(input())
l = input().strip()
l = l.replace(' ', '', l.count(' '))
if '1' in l:
	s = l.find('1')
	e = l.rfind('1')
	x = l[s:e + 1]
	y = x.split('1')
	final = 1
	for i in y:
		final *= len(i) + 1
	print(final)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
c = 0
b = []
for i in range(n):
	if a[i] == 1 and c != 0:
		b.append(c)
		c = 1
	elif a[i] == 1 and c == 0:
		c = 1
	elif c != 0:
		c += 1
if c == 0:
	ans = 0
else:
	ans = 1
for i in range(len(b)):
	ans *= b[i]
print(ans)


a = int(input())
b = list(map(int, input().split()))
ans = 1
k = 0
n = 0
for i in range(a):
	if b[i] == 0:
		if n == 1:
			k += 1
	if b[i] == 1:
		n = 1
		ans = ans * (k + 1)
		k = 0
if b.count(1) == 0:
	ans = 0
print(ans)


from itertools import groupby

def main():
	n = int(input())
	pieces = [bool(int(x)) for x in input().split()]
	if all((not nut for nut in pieces)):
		print(0)
		return
	first_nut = pieces.index(True)
	last_nut = None
	for i in range(len(pieces) - 1, -1, -1):
		if pieces[i]:
			last_nut = i
			break
	new_pieces = pieces[first_nut:last_nut + 1]
	ways = 1
	for (key, group) in groupby(new_pieces):
		if key == True:
			continue
		ways *= sum((1 for _ in group)) + 1
	print(ways)
main()


n = int(input())
L = map(int, input().split())
res = 1
idx = -1
pre = -1
for i in L:
	e = int(i)
	idx = idx + 1
	if e == 1:
		res = res * (idx - pre)
		if pre == -1:
			res = 1
		pre = idx
if pre == -1:
	res = 0
print(res)


n = int(input())
arr = list(map(int, input().split()))
i = 0
flg = False
for i in range(n):
	if arr[i] == 1:
		flg = True
		break
ans = 0
if flg:
	i += 1
	ans = 1
	while i < n:
		ct = 1
		while i < n and arr[i] == 0:
			ct += 1
			i += 1
		if i < n:
			ans *= ct
			i += 1
print(ans)


n = int(input().strip())
arr = input().strip().split()
if '1' not in arr:
	print(0)
else:
	s = ''.join(arr)
	new = s.split('1')
	total = 1
	for i in range(1, len(new) - 1):
		total *= len(new[i]) + 1
	print(total)


n = int(input())
a = list(map(int, input().split()))
ls = []
for i in range(n):
	if a[i]:
		ls.append(i)
ans = 1
if len(ls) == 0:
	print(0)
else:
	for j in range(1, len(ls)):
		ans *= ls[j] - ls[j - 1]
	print(ans)


n = int(input())
ar = list(map(int, input().split()))
s = -1
e = -1
if 1 in ar:
	s = ar.index(1)
	ar.reverse()
	e = len(ar) - ar.index(1)
ar.reverse()
i = s + 1
ans = 1
while i < e:
	count = 1
	t = False
	while i < e and ar[i] == 0:
		count += 1
		i += 1
		t = True
	ans *= count
	if not t:
		i += 1
if s == -1 or e == -1:
	ans = 0
print(ans)


n = int(input())
a = input().replace(' ', '').strip('0')
if a == '':
	print(0)
else:
	curr = 1
	ans = 1
	for i in a:
		if i == '1':
			ans *= curr
			curr = 1
		else:
			curr += 1
	print(ans)


n = int(input())
a = list(map(int, input().split()))
ans = 1
while len(a) > 0 and a[0] == 0:
	a.pop(0)
while len(a) > 0 and a[-1] == 0:
	a.pop(-1)
z = 1
for i in range(1, len(a)):
	if a[i] == 0:
		z += 1
	else:
		ans *= z
		z = 1
if a == []:
	ans = 0
print(ans)


(n, last, res) = (int(input()), -1, 1)
for (i, p) in enumerate(input().split()):
	if p == '1':
		if last != -1:
			res *= i - last
		last = i
print(0) if last == -1 else print(res)


def main():
	temp = input()
	s = input()
	print(solver(s))

def solver(s):
	t = s.replace(' ', '')
	t = t.strip('0')
	t = t.split('1')
	if len(t) == 1:
		return 0
	product = 1
	for zeros in t:
		product *= len(zeros) + 1
	return product
main()


n = int(input())
l = [int(i) for i in input().split()]
s = 0
ans = []
ct = 0
i = 0
if l.count(1) == 0:
	print(0)
elif l.count(1) == 1:
	print(1)
else:
	w = l.index(1)
	l = l[w:]
	for g in range(len(l) - 1, -1, -1):
		if l[g] == 1:
			break
	l = l[:g]
	while i < len(l):
		if s + l[i] <= 1:
			s += l[i]
			ct += 1
			i += 1
		else:
			ans.append(ct)
			ct = 0
			s = 0
	ans.append(ct)
	prod = 1
	for i in ans:
		prod = prod * i
	print(prod)


n = int(input())
a = list(map(int, input().split()))
(curr, last) = (0, 0)
(prod, count) = (1, 0)
if 1 in a:
	last = a.index(1)
for i in range(0, n):
	if a[i] == 1:
		count += 1
		if i != a.index(1):
			last = curr
		curr = i
		if i != a.index(1):
			prod *= curr - last
if count != 0:
	print(prod)
else:
	print(0)


import re
n = int(input())
a = input().split()
start = re.search('1', ''.join(a))
end = re.search('1', ''.join(list(reversed(a))))
if start == None or end == None:
	print(0)
	quit()
start = start.span()[0]
end = n - end.span()[0]
ans = 1
count = 1
for i in range(start, end):
	if a[i] == '1':
		ans *= count
		count = 1
	else:
		count += 1
print(ans)


n = int(input())
lista = input().split()
for i in range(n):
	if lista[i] == '1':
		lista = lista[i:]
		break
else:
	print(0)
	exit()
for i in range(len(lista) - 1, -1, -1):
	if lista[i] == '1':
		lista = lista[:i + 1]
		break
p = [x for x in ''.join(lista).split('1') if x]
soma = 1
for i in p:
	soma *= len(i) + 1
print(soma)


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def mex(li):
	check = [0] * 1001
	for i in li:
		check[i] += 1
	for i in range(len(check)):
		if check[i] == 0:
			return i

def sumdigits(n):
	ans = 0
	while n != 0:
		ans += n % 10
		n //= 10
	return ans

def product(li):
	ans = 1
	for i in li:
		ans *= i
	return ans
from math import *
from collections import deque
max_steps = 100005
for _ in range(1):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(1) <= 1:
		print(a.count(1))
	else:
		b = []
		for i in range(n):
			if a[i] == 1:
				b.append(i)
		c = []
		for i in range(1, len(b)):
			c.append(b[i] - b[i - 1])
		print(product(c))


n = int(input())
L = list(map(int, input().split()))
i = 0
while i < n and L[i] == 0:
	i += 1
if i == n:
	print(0)
else:
	r = 1
	c = 1
	while i < n:
		if L[i]:
			r *= c
			c = 1
		else:
			c += 1
		i += 1
	print(r)


n = int(input())
a = list(map(int, input().split()))
flag = False
for i in range(n):
	if a[i] == 1:
		flag = True
if flag == False:
	print(0)
else:
	res = 1
	for i in range(n):
		if a[i] == 1:
			j = i + 1
			while j < n:
				if a[j] == 1:
					res *= j - i
					break
				j += 1
	print(res)


n = int(input(''))
s = input('').split()
result = 1
oneIndexes = []
for i in range(len(s)):
	if s[i] == '1':
		oneIndexes.append(i)
if len(oneIndexes) == 0:
	print(0)
else:
	for i in range(1, len(oneIndexes)):
		a = oneIndexes[i] - oneIndexes[i - 1]
		result *= a
	print(result)


n = int(input())
l = list(map(int, input().split()))
x = []
flag = True
res = 1
if 1 not in l:
	flag = False
if flag == False:
	print('0')
	exit()
else:
	for i in range(n):
		if l[i] == 1:
			for j in range(i + 1, n):
				if l[j] == 1:
					res = res * (j - i)
					break
print(res)


n = int(input())
string = input()
string = string.split(' ')
values = [0] * 101
j = 0
ans = 1
for i in range(len(string)):
	if string[i] == '1':
		values[j] = i
		j += 1
if j == 0:
	print(0)
else:
	for k in range(j - 1):
		ans *= values[k + 1] - values[k]
	print(ans)


n = int(input())
l = input().split()
x = l.count('1')
p = []
y = 1
if x == 1:
	print(1)
elif x == 0:
	print(0)
else:
	for x in range(n):
		if int(l[x]) == 1:
			p.append(x + 1)
	for x in range(1, len(p)):
		y *= p[x] - p[x - 1]
	print(y)


n = int(input())
arr = list(map(int, input().split()))
ind = []
for i in range(len(arr)):
	if arr[i] == 1:
		ind.append(i)
med = len(ind)
pro = 0
if med == 0:
	pro = 0
else:
	pro = 1
	if med != 1:
		for i in range(1, med):
			pro = pro * (ind[i] - ind[i - 1])
print(pro)


n = int(input())
lis = list(map(int, input().split()))
if max(lis) == 0:
	print(0)
	exit()
prev = 0
ans = 1
flag = False
for i in range(n):
	if lis[i] == 1:
		ans *= prev + 1
		flag = True
		prev = 0
	elif flag:
		prev += 1
print(ans)


(p, c, a, b) = (int(input()), list(map(int, input().split())), 1, [])
if c.count(0) == p:
	print(0)
elif c.index(1) != p - 1:
	l = c.index(1)
	for i in range(l + 1, p):
		if c[i] == 1:
			b.append(i - l)
			l = i
	for i in b:
		a *= i
	print(a)
else:
	print(1)


def breakit(data):
	breaks = 0
	pos = []
	for i in range(len(data)):
		if data[i] == 1:
			pos.append(i + 1)
	if len(pos) == 0:
		breaks = 0
	else:
		breaks = 1
		for i in range(len(pos) - 1):
			breaks *= pos[i + 1] - pos[i]
	return breaks
n = int(input())
data = list(map(int, input().replace(' ', '')))
print(breakit(data))


n = eval(input())
l = list(map(int, input().split()))
i = 0
d = True
(i1, i2) = (10, 10)
while i <= n - 1 and d == True:
	if l[i] == 1:
		i1 = i
		d = False
	i += 1
i = len(l) - 1
d = True
while i >= 0 and d == True:
	if l[i] == 1:
		i2 = i
		d = False
	i -= 1
x = []
f = 1
if i1 == 10 and i2 == 10:
	print(0)
elif i1 == i2:
	print(1)
else:
	while i1 < i2:
		if l[i1 + 1] == 0:
			f += 1
		else:
			x = x + [f]
			f = 1
		i1 += 1
	i = 0
	sum = 1
	while i <= len(x) - 1:
		sum = sum * x[i]
		i += 1
	print(sum)


import math

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
n = int(input())
posprev = None
ans = 0
input_array = list(map(int, input().split()))
for (i, e) in enumerate(input_array):
	if e == 1 and posprev == None:
		posprev = i
		ans = 1
	elif e == 1:
		ans *= i - posprev
		posprev = i
	else:
		continue
if ans == 0:
	print(0)
elif ans == 1:
	print(1)
else:
	print(ans)


def solve(a, n):
	if a.count(1) == 0:
		return 0
	ans = 1
	ind = []
	for i in range(n):
		if a[i] == 1:
			ind.append(i)
	for i in range(1, len(ind)):
		ans = ans * (ind[i] - ind[i - 1])
	return ans
n = int(input())
a = list(map(int, input().split()))
print(solve(a, n))


indexes = []
n = int(input())
s = list(map(str, input().split()))
a = ''.join(s)
a = a.lstrip('0')
a = a.rstrip('0')
for i in range(len(a)):
	if a[i] == '1':
		indexes.append(i)
ans = 1
for i in range(len(indexes) - 1):
	ans *= indexes[i + 1] - indexes[i]
if len(a) == 0:
	ans = 0
print(ans)


n = int(input())
a = input()
hadOne = False
ways = 1
x = 0
hadOne = False
for i in a:
	if i == '1':
		if hadOne:
			if x != 0:
				ways *= x + 1
		x = 0
		hadOne = True
	elif i == '0':
		x += 1
if not hadOne:
	print(0)
else:
	print(ways)


def main():
	n = int(input())
	barra = input().split()
	barra = [int(x) for x in barra]
	i = 0
	while i < n and barra[i] == 0:
		i += 1
	f = n - 1
	while f >= 0 and barra[f] == 0:
		f -= 1
	barra = barra[i:f + 1]
	if barra == []:
		print(0)
		return
	soma = [1]
	for i in range(1, len(barra)):
		soma.append(soma[-1] + barra[i])
	freq = {}
	for i in range(1, soma[-1] + 1):
		freq[i] = 0
	for num in soma:
		freq[num] += 1
	total = 1
	for f in freq.values():
		total = total * f
	if soma == []:
		total = 0
	print(total)
main()


n = int(input())
ip = list(map(int, input().split()))
c = ip.count(1)
ans = 1
i = 0
i2 = 0
if c == 0:
	print(0)
elif c == 1:
	print(ans)
else:
	for j in range(c - 1):
		i = ip.index(1, i2)
		i2 = ip.index(1, i + 1)
		ans = ans * (i2 - i)
	print(ans)


n = int(input())
choc = input().split()
index = 0
aux = 0
ans = 1
while index < n:
	if choc[index] == '1' and index < n - 1:
		index += 1
		aux = 0
		while choc[index] == '0':
			aux += 1
			index += 1
			if index >= n:
				break
		else:
			ans *= aux + 1
	else:
		index += 1
if ans == 1 and set(choc) == set(['0']):
	ans = 0
print(ans)


n = int(input())
ls = list(map(int, input().split()))
tot = sum(ls)
answer = 1
i = 0
stack = []
while i < n:
	if ls[i]:
		if stack:
			dis = i - stack[-1]
			answer *= dis
		stack.append(i)
	i += 1
if tot == 0:
	answer = 0
print(answer)


x = int(input())
z = list(map(int, input().split()))
if 1 not in z:
	print(0)
else:
	ans = 1
	idx = z.index(1)
	a = idx
	for i in range(idx + 1, x):
		if z[i] == 1:
			ans *= i - a
			a = i
	print(ans)


n = int(input())
c = 0
seen = 0
ans = 1
l = [int(i) for i in input().split()]
for i in range(n):
	if l[i] == 0 and seen:
		c += 1
	elif l[i] == 1:
		if not seen:
			seen = 1
		else:
			if c > 0:
				ans *= c + 1
			c = 0
if 1 not in l:
	print(0)
elif ans == 0:
	print(1)
else:
	print(ans)


x = input()
lista = list(map(int, input().lstrip('0 ').rstrip(' 0').split()))
resp = []
cont = 1
for i in lista:
	if i == 1:
		resp.append(cont)
		cont = 1
	else:
		cont += 1
multi = 1
for i in resp:
	multi *= i
if len(lista) == 0:
	print(0)
else:
	print(multi)


n = int(input())
li = list(map(int, input().split()))
index = [i for i in range(0, n) if li[i] == 1]
if li.count(1) == 0:
	(print(0), exit(0))
ans = 1
for i in range(0, len(index) - 1):
	ans *= index[i + 1] - index[i]
print(ans)


n = int(input())
ar = list(map(int, input().split()))
f = 0
suma = 0
res = 1
for i in range(len(ar)):
	if f:
		if ar[i] == 0:
			suma += 1
		elif suma > 0:
			res = res * (suma + 1)
			suma = 0
	if ar[i] == 1:
		f = 1
print(res if f else 0)


n = int(input())
l = list(map(int, input().split(' ')))
ll = [i for i in range(n) if l[i] == 1]
if len(ll) == 1:
	print(1)
	exit()
if len(ll) == 0:
	print(0)
	exit()
ans = ll[1] - ll[0]
for i in range(2, len(ll)):
	ans *= ll[i] - ll[i - 1]
print(ans)


n = int(input())
arr = list(map(int, input().strip().split()))
prev = 0
(tillnow, ways) = (0, 1)
for idx in range(n):
	if arr[idx] == 1:
		if tillnow:
			ways *= idx - prev
		tillnow += 1
		prev = idx
if tillnow:
	print(ways)
else:
	print(0)


n = int(input())
l = [int(i) for i in input().split()]
k = []
ind = 0
if l.count(1) == 0:
	print(0)
else:
	for i in l:
		if i == 1:
			k.append(ind)
		ind += 1
	prd = 1
	for i in range(1, len(k)):
		prd *= k[i] - k[i - 1]
	print(prd)


n = int(input())
a = list(map(int, input().split()))
k = 1
last = 0
c = 0
if a.count(1) == 0:
	print('0')
	exit()
for i in range(n):
	if a[i] == 1:
		if c == 0:
			last = i
			c = 1
		else:
			k = k * (i - last)
			last = i
print(k)


n = int(input())
a = [int(x) for x in input().split()]
i = 0
ways = []
while i < n:
	if a[i] != 0:
		break
	i += 1
if i == n:
	print(0)
	exit()
i = 0
while i < n:
	count = 0
	if a[i] == 1:
		while i < n and a[i] == 1:
			i += 1
		while i < n and a[i] == 0:
			i += 1
			count += 1
		if i == n:
			if a[i - 1] == 0:
				ways.append(1)
			else:
				ways.append(count + 1)
		elif i != n:
			ways.append(count + 1)
	else:
		i += 1
res = 1
for w in ways:
	res *= w
print(res)


n = int(input())
pedacos = list(map(int, input().split()))
j = 0
k = 1
ans = 1
veri = True
countOne = 0
while j < len(pedacos):
	e = pedacos[j]
	if e == 1:
		countOne += 1
		if k != 0 and (not veri):
			ans *= k + 1
		veri = False
		k = 0
	elif e == 0 and (not veri):
		k += 1
	j += 1
if countOne == 0:
	print(0)
else:
	print(ans)


from itertools import dropwhile

def main():
	n = int(input())
	lst = [bool(int(x)) for x in input().split()]
	lst = list(dropwhile(lambda x: not x, lst))
	if not lst:
		print(0)
		return
	ans = 1
	cnt = 1
	for x in lst:
		if x:
			if cnt > 1:
				ans *= cnt
				cnt = 1
		else:
			cnt += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


n = int(input())
L = map(int, input().split())
z = 0
x = 1
f = False
for i in L:
	if i == 1:
		if not f:
			f = True
			z = 1
		else:
			z *= x
		x = 0
	if f:
		x += 1
print(z)


n = int(input())
a = list(map(int, input().split()))
k = sum(a)
if k == 0:
	print(0)
	exit()
oneMet = False
d = 1
p = 0
for i in range(n):
	if a[i] == 1:
		p += 1
		if oneMet:
			d *= p
		oneMet = True
		p = 0
		k -= 1
	if k == 0:
		break
	if a[i] == 0:
		p += 1
print(d)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from itertools import permutations as pmt
n = int(input())
arr = list(map(int, input().split()))
var = 1
pre = -1
for i in range(n):
	if arr[i] == 1:
		if pre != -1:
			var *= i - pre - 1 + 1
		else:
			pass
		pre = i
print(max(1, var) if 1 in arr else 0)


n = int(input())
a = [int(i) for i in input().split()]
f = False
c = []
k = 1
for v in a:
	if v == 0:
		k += 1
	else:
		if f:
			c += [k]
		k = 1
		f = True
if not f:
	print(0)
else:
	p = 1
	for v in c:
		p *= v
	print(p)


n = int(input())
inp = input()
if '1' in inp:
	p = ''.join(inp.split(' ')).split('1')[1:-1]
	x = 1
	for n in (len(x) + 1 for x in p):
		x *= n
	print(x)
else:
	print(0)


n = int(input())
a = [str(i) for i in input().split()]
b = ''.join(a)
b = b.strip('0')
if len(b):
	(k, h, i) = (1, 0, 0)
	while i < len(b) - 1:
		if b[i] == '1':
			h = 0
			for j in range(i + 1, len(b)):
				if b[j] == '0':
					h += 1
				else:
					i = j
					break
			k *= h + 1
	print(k)
else:
	print(0)


from collections import defaultdict, deque, Counter, OrderedDict

def main():
	a = int(input())
	l = [int(i) for i in input().strip().split()]
	ind = []
	for i in range(a):
		if l[i] == 1:
			ind.append(i)
	if len(ind) == 1 or len(ind) == 0:
		print(len(ind))
	else:
		ans = 1
		for i in range(1, len(ind)):
			ans = ans * (ind[i] - ind[i - 1])
		print(ans)
main()


n = int(input())
A = [int(a) for a in input().split()]
ans = 1
last_one = -1
for i in range(n):
	if last_one != -1:
		if A[i] == 1:
			ans *= i - last_one
			last_one = i
	elif A[i] == 1:
		last_one = i
zeroes = A.count(0)
if zeroes == n:
	print(0)
else:
	print(ans)


n = int(input())
aa = list(map(int, input().split()))
if sum(aa) == 0:
	print(0)
	exit(0)
first = aa.index(1)
last = n - aa[::-1].index(1)
res = 1
cnt = 0
for i in range(first, last):
	if aa[i] == 1:
		res *= cnt + 1
		cnt = 0
	else:
		cnt += 1
print(res)


import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
s = sum(a)
if s == 0:
	print(0)
elif s == 1:
	print(1)
else:
	i = a.index(1)
	a[:i + 1] = []
	ans = 1
	for _ in range(s - 1):
		i = a.index(1)
		ans *= i + 1
		a[:i + 1] = []
	print(ans)


n = int(input())
t = list(map(int, input().split()))
if sum(t) == 0:
	print(0)
else:
	last = -1
	ans = 1
	for j in range(n):
		if t[j] == 1:
			if last == -1:
				last = j
			else:
				ans *= j - last
				last = j
	print(ans)


n = int(input())
li = input().split(' ')
prev_one = -1
num_of_ways = 1
i = 0
while i < len(li):
	if li[i] == '1':
		if prev_one != -1 and i - prev_one > 1:
			num_of_ways *= i - prev_one
			prev_one = i
		else:
			prev_one = i
	i += 1
if num_of_ways == 1 and prev_one == -1:
	print(0)
else:
	print(num_of_ways)


n = int(input())
l = list(map(int, input().split()))
temp = []
for i in range(n):
	if l[i] == 1:
		temp.append(i)
if len(temp) == 0:
	print(0)
elif len(temp) == 1:
	print(1)
else:
	ys = 1
	for i in range(1, len(temp)):
		bs = temp[i] - temp[i - 1]
		ys = ys * bs
	print(ys)


n = int(input())
f = list(map(int, input().split()))
ans = 1
now = -1
for i in range(n):
	if f[i]:
		if now != -1:
			ans = ans * (i - now)
		now = i
if now == -1:
	ans = 0
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
ans = 1
prev = -1
i = 0
while i < n:
	if a[i] == 1:
		prev = i
		i += 1
		break
	i += 1
while i < n:
	if a[i] == 1:
		ans *= i - prev
		prev = i
	i += 1
if prev == -1:
	print(0)
else:
	print(ans)


n = int(input())
chocolate = input().split()
breaks = 1
idx_controller = 0
while idx_controller < len(chocolate) and chocolate[idx_controller] != '1':
	idx_controller += 1
if idx_controller == len(chocolate):
	breaks = 0
multiply = 1
for idx_controller in range(idx_controller, len(chocolate)):
	if chocolate[idx_controller] == '0':
		multiply += 1
	else:
		breaks *= multiply
		multiply = 1
print(breaks)


n = int(input())
li = list(map(int, input().split()))
while n > 0:
	f = 0
	if li[0] == 0:
		f = 1
		li.pop(0)
		n -= 1
	elif li[-1] == 0:
		f = 1
		li.pop()
		n -= 1
	if f == 0:
		break
cnt = 1 if len(li) > 0 else 0
sm = 1
for i in li:
	if i == 1:
		cnt *= sm
		sm = 1
	else:
		sm += 1
cnt *= sm
print(cnt)


import time
n = int(input())
a = [int(i) for i in input().split()]
start = time.time()
s = sum(a)
if s == 0:
	ans = 0
elif s == 1:
	ans = 1
else:
	ans = 1
	l = 0
	while a[l] != 1:
		l += 1
	r = l
	while r < n - 1:
		r += 1
		if a[r] == 1:
			ans *= r - l
			l = r
print(ans)
finish = time.time()


n = int(input())
l = tuple(map(int, input().split()))
res = 1
if l == (0,) * n:
	print(0)
else:
	k = 0
	f = 0
	for i in range(n):
		if l[i] == 1:
			f = 1
			res = res * k if k != 0 else res
			k = 0
		if not f:
			continue
		k += 1
	print(res)


n = input()
L = map(int, input().split())
ans = 0
cnt = -1
pre = -1
for i in L:
	cnt += 1
	if i == 1:
		ans = ans * (cnt - pre)
		if pre == -1:
			ans = 1
		pre = cnt
print(ans)


n = int(input())
chocolate = list(map(int, input().split(' ')))
cnt = chocolate.count(1)
if cnt == 0:
	print(0)
elif cnt == 1:
	print(1)
else:
	j = 0
	for i in range(n):
		if chocolate[i]:
			j = i
			break
	t = j
	ans = 1
	for i in range(n):
		if i == t:
			continue
		if chocolate[i]:
			ans *= i - j
			j = i
	print(ans)


n = int(input())
l = list(map(int, input().split()))
if not 1 in l:
	print(0)
else:
	j = l.index(1)
	ans = 1
	for i in range(j + 1, n):
		if l[i] == 1:
			ans *= i - j
			j = i
	print(ans)


n = int(input())
a = list(map(int, input().split()))
result = 1
flag = False
res = 1
for i in a:
	if i == 1 and flag:
		result *= res
		res = 1
	if i == 1:
		flag = True
	if i == 0 and flag:
		res += 1
if not flag:
	print(0)
else:
	print(result)


n = 0
pieces = []
hayNueces = 0
numZ = 1
res = 1
n = int(input())
pieces = input()
pieces = [int(i) for i in pieces.split()]
hayNueces = sum((int(i) for i in pieces))
i = 0
while i < n and pieces[i] == 0:
	i += 1
while i < n:
	(res, numZ) = (res * numZ, 1) if pieces[i] == 1 else (res, numZ + 1)
	i += 1
print('0' if hayNueces <= 0 else res)


l = input().strip()
n = input().strip()
if not n.__contains__('1'):
	print('0')
else:
	x = n[::-1].index('1')
	n = n[:len(n) - x]
	x = n.index('1')
	n = n[x:]
	s = n.split('1')
	if s[0] != '':
		s = s[s.index(''):]
	s = [i.strip() for i in s if i.strip() != '']
	f = 1
	for i in s:
		f *= i.count('0') + 1
	print(f)


n = int(input())
a = list(map(int, input().split()))
while a and a[0] != 1:
	del a[0]
while a and a[-1] != 1:
	a.pop()
if len(a) < 2:
	print(len(a))
	exit(0)
c = 1
l = [i for (i, x) in enumerate(a) if x == 1]
for i in range(1, len(l)):
	c *= l[i] - l[i - 1]
print(c)


import math

def ncr(n, r):
	f = math.factorial
	return f(n) / f(r) / f(n - r)
r = 0
ones = []
n = int(input())
a = list(map(int, input().split()))
for i in range(0, n):
	if a[i] == 1:
		ones.append(i)
if len(ones) == 0:
	print(0)
else:
	res = 1
	for i in range(1, len(ones)):
		res *= ones[i] - ones[i - 1]
	print(res)


pedacos = int(input())
nozes = input().split()
anterior = -1
resposta = 0
for i in range(pedacos):
	p = nozes[i]
	if p == '1':
		if anterior == -1:
			resposta = 1
		else:
			resposta *= i - anterior
		anterior = i
print(resposta)


N = int(input())
A = [int(x) for x in input().split()]
ans = 1
prev = -1
for i in range(len(A)):
	if A[i] == 1 and prev != -1:
		ans *= i - prev
		prev = i
	elif A[i] == 1:
		prev = i
if prev == -1:
	print(0)
else:
	print(ans)


n = int(input())
arr = list(map(int, input().split()))
cut = sum(arr)
if cut == 0:
	print(0)
else:
	li = []
	for i in range(n):
		if arr[i] & 1:
			li.append(i)
	ans = 1
	for i in range(1, len(li)):
		ans *= li[i] - li[i - 1]
	print(ans)


n = int(input())
a = [int(i) for i in input().split()]
if a.count(1) == 0:
	print(0)
else:
	num_of_ways = 1
	diff = 1
	flag = 0
	for a_i in a:
		if a_i == 1:
			if flag == 1:
				num_of_ways *= diff
			else:
				flag = 1
			diff = 1
		else:
			diff += 1
	print(num_of_ways)


import functools
import operator
import re
rx = re.compile('0+')
try:
	while True:
		n = int(input())
		s = ''.join(input().split()).strip('0')
		if s:
			print(functools.reduce(operator.mul, map(lambda m: len(m.group()) + 1, rx.finditer(s)), 1))
		else:
			print(0)
except EOFError:
	pass


n = int(input())
cb = [int(i) for i in input().split()]
res = 1
curr = 1
start = False
for a in cb:
	if a == 1:
		if start:
			res *= curr
		else:
			start = True
		curr = 1
	else:
		curr += 1
if not start:
	print(0)
else:
	print(res)


n = int(input())
a = list(map(int, input().split()))
mult = []
pos1 = -1
pos2 = -1
for i in range(len(a)):
	if a[i] == 1 and pos1 == -1:
		pos1 = i
	elif a[i] == 1 and pos1 != -1:
		pos2 = i
		mult.append(pos2 - pos1)
		pos1 = pos2
ans = 1
for i in mult:
	ans *= i
if a.count(0) == len(a):
	print(0)
else:
	print(ans)


n = int(input())
a = input().replace(' ', '')
this = a.split('1')
if len(this) == 1:
	print(0)
else:
	ans = 1
	for i in range(1, len(this) - 1):
		if this[i] == '':
			pass
		else:
			ans *= len(this[i]) + 1
	print(ans)


n = int(input())
l = list(map(int, input().split()))
if l.count(1) == 0:
	print(0)
elif l.count(1) == 1:
	print(1)
else:
	R = False
	B = 0
	Y = 1
	for i in range(len(l)):
		if l[i] == 1:
			if R:
				Q = i - B
				Y *= Q
			R = True
			B = i
	print(Y)


n = int(input())
a = list(map(int, input().split()))
b = []
cur = -1
for i in a:
	if i == 1:
		if cur != -1:
			b.append(cur)
		cur = 0
	elif cur != -1:
		cur += 1
ans = 1
for i in b:
	ans *= i + 1
if cur == -1:
	ans = 0
print(ans)


n = int(input())
cnt = []
a = ''.join(input().split())
ss = 0
res = 1
if a.count('0') == n:
	print(0)
	quit()
start = False
end = False
for i in range(n):
	if a[i] == '0' and start == True:
		ss += 1
	if a[i] == '1' and start == False:
		start = True
	if a[i] == '1' and start == True and (end == False):
		res *= ss + 1
		ss = 0
print(res)


n = int(input())
z = list(map(int, input().split()))
c = 0
l = []
s = 0
for i in range(n):
	if z[i] == 1:
		s = 1
		l.append(c + 1)
		c = 0
	else:
		c += 1
if s == 1:
	l.pop(0)
	c = 1
	for i in l:
		c *= i
	print(c)
else:
	print(0)


n = int(input())
li = input().split()
li = ''.join(li)
k = li.count('1')
if k == 1 or k == len(li):
	print(1)
elif k == 0:
	print(0)
else:
	nof = 1
	if '1' in li:
		end = li.rindex('1')
	else:
		li = ''
	while li:
		li = li[:end]
		if '1' in li:
			nof *= end - li.rindex('1')
			end = li.rindex('1')
		else:
			li = ''
	print(nof)


n = int(input())
a = list(map(int, input().split()))
if a.count(1) == 1:
	print(1)
	exit()
elif a.count(1) == 0:
	print(0)
	exit()
c = []
count = 1
for i in range(a.index(1) + 1, n):
	if a[i] == 1:
		c.append(count)
		count = 1
	else:
		count += 1
ans = 1
for i in c:
	ans = ans * i
print(ans)


def calc():
	n = int(input())
	a = list(map(int, input().split(' ')))
	p = []
	for i in range(n):
		if a[i] == 1:
			p.append(i)
	if len(p) == 0:
		return 0
	elif len(p) == 1:
		return 1
	else:
		ans = 1
		for i in range(1, len(p)):
			ans *= p[i] - p[i - 1]
		return ans
print(calc())


n = int(input())
a = [int(i) for i in input().split()]
if 1 not in a:
	print(0)
	exit(0)
cur = a.index(1)
ans = []
for i in range(a.index(1), n):
	if a[i] == 1:
		ans.append(i - cur)
		cur = i
ans.pop(0)
mul = 1
for i in ans:
	mul *= i
print(mul)


n = int(input())
s = input()
s = s.replace(' ', '')
c = 0
for i in range(len(s)):
	if s[i] == '1':
		c = c + 1
l = s.split('1')
l[0] = ''
l[-1] = ''
l1 = []
for i in l:
	l1.append(len(i) + 1)
ans = 1
for i in l1:
	ans = ans * i
if c != 0:
	print(ans)
else:
	print(0)


from math import factorial
n = int(input())
choc = list(map(int, input().split()))
prev = -1
res = 0
for i in range(n):
	if choc[i] == 1:
		if prev == -1:
			res = 1
		else:
			res *= i - prev
		prev = i
print(res)


n = int(input())
a = list(map(int, input().split()))
ans = 1
i = 0
while i < n and a[i] != 1:
	i += 1
if i == n:
	ans = 0
cur = 1
for j in range(i + 1, n):
	if a[j] == 1:
		ans *= cur
		cur = 1
	else:
		cur += 1
print(ans)


n = int(input())
s = input()
s = s.split()
zeroes = 0
ans = 1
firstonefound = False
initial_zeroes = 0
for i in range(n):
	if s[i] == '0':
		zeroes += 1
	elif firstonefound:
		if zeroes == 0:
			continue
		else:
			ans *= zeroes + 1
			zeroes = 0
	else:
		firstonefound = True
		zeroes = 0
if s.count('1') == 0:
	ans = 0
elif s.count('0') == 0:
	ans = 1
print(ans)


n = int(input())
numbers = input().split()
i = 0
while i < n and numbers[i] == '0':
	i += 1
j = n - 1
while j >= 0 and numbers[j] == '0':
	j -= 1
aux = []
for k in range(i, j + 1):
	aux.append(numbers[k])
i = 0
zeros = 0
result = 0
if len(aux) > 0:
	result = 1
	while i < len(aux):
		if aux[i] == '0':
			zeros += 1
		else:
			result *= zeros + 1
			zeros = 0
		i += 1
print(result)


n = int(input())
ar = list(map(int, input().split()))
prev = -1
p = 1
flag = 0
for i in range(n):
	if ar[i] == 1:
		if prev == -1:
			prev = i
		else:
			p *= abs(i - prev)
			prev = i
		flag = 1
print(p if flag else 0)


n = int(input())
isnut = [int(x) == 1 for x in input().split()]
ans = 1
stack = 1
hasnut = False
for nut in isnut:
	if nut:
		if hasnut:
			ans *= stack
			stack = 1
		else:
			hasnut = True
			stack = 1
	else:
		stack += 1
print(ans if hasnut else 0)


n = int(input())
choko = list(map(int, input().split()))
ans = 1
if choko.count(1) > 0:
	while choko.count(1) > 1:
		fone = choko.index(1)
		choko = choko[fone + 1:]
		sone = choko.index(1)
		ans *= sone + 1
		choko = choko[sone:]
	print(ans)
else:
	print(0)


n = int(input())
nuts = list(map(str, input().split()))
ans = 1
cur = 1
isone = False
for i in range(n):
	if nuts[i] == '1':
		isone = True
		ans *= cur
		cur = 1
	elif isone:
		cur += 1
if isone:
	print(ans)
else:
	print(0)


input()
pattern = ''.join(input().split()).rstrip('0').lstrip('0')

def solve(pattern):
	multiplier = 1
	currentIndex = 0
	if pattern == '':
		return '0'
	while True:
		index = pattern.find('0', currentIndex)
		if index == -1:
			return multiplier
			break
		else:
			currentIndex = pattern.find('1', index)
			multiplier *= currentIndex - index + 1
print(solve(pattern))


import sys
LI = lambda : list(map(int, sys.stdin.readline().split()))
MI = lambda : map(int, sys.stdin.readline().split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline())
n = II()
a = LI()
ans = 0
if a.count(1):
	i = a.index(1)
	ans = 1
	while i < n:
		j = i + 1
		while j < n and a[j] == 0:
			j += 1
		if j < n:
			ans *= j - i
		i = j
print(ans)


n = int(input())
R = lambda : map(int, input().split())
a = list(R())
an = [i for (i, v) in enumerate(a, 0) if v == 1]
if len(an) == 0:
	print(0)
else:
	an = [an[i] - an[i - 1] for i in range(1, len(an))]
	res = 1
	for i in an:
		res *= i
	print(res)


n = int(input())
a = list(map(int, input().split()))
k = a.count(1)
answer = 1
if k == 0:
	print(0)
else:
	if k == n or k == 1:
		answer = 1
	else:
		curk = 0
		zero = 0
		for i in range(n):
			if a[i]:
				answer *= zero + 1
				zero = 0
				curk += 1
				if curk == k:
					break
			elif curk:
				zero += 1
	print(answer)


_ = input()
choco = list(map(int, input().split()))
found_one = False
zeroes = 0
ways = 0
for piece in choco:
	if piece == 1 and (not found_one):
		found_one = True
		zeroes = 0
		ways = 1
	elif piece == 1:
		ways *= zeroes + 1
		zeroes = 0
	elif piece == 0:
		zeroes += 1
print(ways)


import random, math
from copy import deepcopy as dc

def randomNumber(s, e):
	return random.randint(s, e)

def randomArray(s, e, s_size, e_size):
	size = random.randint(s_size, e_size)
	arr = [randomNumber(s, e) for i in range(size)]
	return arr

def testcase():
	pass

def brute():
	pass

def effe():
	pass

def solution(li, n):
	last = -1
	ways = 1
	for i in range(n):
		if li[i] == 1 and last != -1:
			diff = i - last
			ways *= diff
			last = dc(i)
		elif li[i] == 1:
			last = dc(i)
	return ways if last != -1 else 0

def input_test():
	n = int(input())
	li = list(map(int, input().strip().split(' ')))
	out = solution(li, n)
	print(out)

def test():
	pass
input_test()


n = int(input())
line = input().split()
ans = 1
last = -1
for i in range(0, len(line)):
	if line[i] == '1':
		if last == -1:
			last = i
		else:
			ans *= i - last
			last = i
if last == -1:
	ans = 0
print(ans)


n = int(input())
a = input().split()
while len(a) > 0 and a[0] == '0':
	a = a[1:]
while len(a) > 0 and a[-1] == '0':
	a = a[:-1]
if len(a) == 0:
	print(0)
else:
	ans = 1
	zeros = 0
	for x in a:
		if x == '0':
			zeros += 1
		else:
			ans *= zeros + 1
			zeros = 0
	print(ans)


n = int(input())
seq = list(map(int, input().split()))
ans = 1
tmp = 0
flag = False
for (i, v) in enumerate(seq):
	if v == 1:
		flag = True
		ans *= tmp + 1
		tmp = 0
	if flag and v == 0:
		tmp += 1
print(ans if flag else 0)


n = int(input())
seq = list(map(int, input().split()))
startindex = 0
for i in seq:
	if i != 1:
		startindex += 1
	else:
		break
if startindex < n:
	ans = 1
	nuts = 0
	cuts = 0
	for i in seq[startindex:]:
		if i != 1:
			cuts += 1
		else:
			nuts += 1
			if cuts != 0:
				ans *= cuts
			cuts = 1
	if nuts == 1:
		ans = 1
else:
	ans = 0
print(ans)


n = int(input())
a = list(map(int, input().split()))
p = 1
d = 0
c = 1
i = 0
while i < n and d < n:
	if a[i] == 1:
		if d > 0 and d < n:
			p *= c
		d += 1
		c = 1
	else:
		c += 1
	i += 1
if d == 0:
	print(0)
else:
	print(p)


n = int(input())
A = list(map(int, input().split()))
D = []
if A.count(1) == 0:
	print(0)
elif A.count(1) == 1:
	print(1)
else:
	p = A.index(1)
	for i in range(p + 1, n):
		if A[i] == 1:
			D.append(i - p)
			p = i
	P = 1
	for i in D:
		P = P * i
	print(P)


(n, a, v) = (int(input()), list(map(int, input().split())), 1)
p = [i for (i, ai) in enumerate(a) if ai]
for i in range(1, len(p)):
	v *= p[i] - p[i - 1]
print(v if p else 0)


n = int(input())
prev = -1
k = 1
flag = False
for (i, el) in enumerate(input().split()):
	if el == '1':
		flag = True
		if prev != -1:
			k *= i - prev
		prev = i
if flag:
	print(k)
else:
	print(0)


n = int(input())
lst = [int(i) for i in input().split()]
num = []
for i in range(n):
	if lst[i] == 1:
		num.append(i)
if len(num) == 0:
	print(0)
elif len(num) == 1:
	print(1)
else:
	res = 1
	for j in range(1, len(num)):
		res = res * (num[j] - num[j - 1])
	print(res)


n = int(input())
a = list(map(int, input().split()))
x = 1
if sum(a) == 0:
	print(0)
else:
	l = 0
	while a[l] == 0:
		l += 1
	r = n - 1
	while a[r] == 0:
		r -= 1
	c = 1
	for i in range(l, r + 1):
		if a[i] == 1:
			x *= c
			c = 1
		else:
			c += 1
	print(x)


N = int(input())
choco = [int(x) for x in input().split()]
if all((c == 0 for c in choco)):
	print(0)
	exit(0)
ans = 1
i = 0
while choco[i] == 0:
	i += 1
while True:
	assert choco[i] == 1
	j = i + 1
	while j < N and choco[j] == 0:
		j += 1
	if j == N:
		break
	else:
		ans *= j - i
	i = j
print(ans)


n = int(input())
a = [int(i) for i in input().split()]
ans = 1
if 1 not in a:
	print(0)
else:
	j = a.index(1)
	for i in range(j + 1, len(a)):
		if a[i] == 1:
			ans = ans * (i - j)
			j = i
	print(ans)


t = int(input())
l_n = list(input().split())
p_1 = None
t = 1
for i in range(len(l_n)):
	if l_n[i] == '1':
		if p_1 == None:
			p_1 = i
		else:
			t *= i - p_1
			p_1 = i
print(t if p_1 != None else 0)


n = int(input())
arr = [int(i) for i in input().split()]
cnt = arr.count(1)
res = 1
if cnt < 2:
	print(cnt)
else:
	pos = arr.index(1)
	for i in range(cnt):
		if i != cnt - 1:
			nextpos = arr.index(1, pos + 1)
			res *= nextpos - pos
			pos = nextpos
	print(res)


n = int(input())
a = list(map(int, input().split()))
f = -1
l = -1
for i in range(0, n):
	if a[i] == 1:
		f = i
		break
for i in range(n - 1, -1, -1):
	if a[i] == 1:
		l = i
		break
c = 0
ans = 1
for i in range(f, l + 1):
	c += 1
	if a[i] == 1:
		ans = ans * c
		c = 0
if f == -1:
	print(0)
else:
	print(ans)


def ways(s):
	if len(s) == 1:
		return 1
	count = 1
	i = 1
	while True:
		if s[i] == '0':
			count += 1
		else:
			break
		i += 1
	return count * ways(s[i:])
n = int(input())
s = input()
s = s.replace(' ', '')
if '1' in s:
	s = s[s.index('1'):s.rindex('1') + 1]
	print(ways(s))
else:
	print('0')


n = int(input())
lst = list(map(int, input().split()))
one = 0
for x in lst:
	if x == 1:
		one += 1
flag = 0
zero = 0
temp = 1
i = 0
a = list()
if one == 0:
	print(0)
elif one == 1:
	print(1)
elif one > 1:
	while i < n:
		if lst[i] == 1 and flag < one:
			if flag == 0:
				flag += 1
			for j in range(i + 1, n):
				if lst[j] == 1:
					a.append(zero + 1)
					flag += 1
					i = j
					zero = 0
					break
				else:
					zero += 1
		else:
			i += 1
	for i in range(len(a)):
		temp *= a[i]
	print(temp)


n = int(input())
a = list(map(int, input().split()))
lis = list()
for i in range(n):
	if a[i] == 1:
		lis.append(i)
if len(lis) < 2:
	print(len(lis))
else:
	ans = 1
	for i in range(len(lis) - 1):
		ans *= lis[i + 1] - lis[i]
	print(ans)


n = int(input())
l = list(map(int, input().split()))
ans = 1
cnt = 1
start = False
for i in l:
	if i == 1:
		start = True
		ans *= cnt
		cnt = 1
	if i == 0 and start:
		cnt += 1
if l.count(1) == 0:
	print(0)
else:
	print(ans)


input()
a = list(map(int, input().strip('0 ').split()))
n = len(a)
(cnt_z, cnt) = (0, 1)
if n == 0:
	cnt = 0
for i in range(n):
	if a[i] == 1:
		cnt *= cnt_z + 1
		cnt_z = 0
	else:
		cnt_z += 1
print(cnt)


def main(L):
	res = 0
	idx = -1
	pre = -1
	for e in L:
		idx += 1
		if e == 1:
			res = res * (idx - pre)
			if pre == -1:
				res = 1
			pre = idx
	return str(res)
input()
print(main(map(int, input().split())))


(res, n, s) = (1, int(input()), input())
if s.count('1') == 0:
	print(0)
else:
	for item in ''.join(s.split()).strip('0').split('1'):
		res *= len(item) + 1
	print(res)


n = int(input())
pos = []
t = [int(i) for i in input().split(' ')]
for i in range(n):
	if t[i]:
		pos.append(i)
if len(pos) == 0:
	print(0)
elif len(pos) == 1:
	print(1)
else:
	c = 1
	for i in range(1, len(pos)):
		c *= pos[i] - pos[i - 1]
	print(c)


inn = input()
string = input()
count = 0
total = 0
arr = []
for i in string:
	if count == 0:
		if i == '1':
			count = 1
			total = 1
	elif i == '1':
		total *= count
		count = 1
	elif i == '0':
		count += 1
print(total)


n = int(input())
a = []
sp = -1
ep = 0
for x in input().split():
	a.append(int(x))
	if int(x) == 1:
		if sp == -1:
			sp = len(a)
		ep = len(a)
c = 1
o = 1
for i in range(sp, ep):
	if a[i] == 0:
		c += 1
	else:
		o *= c
		c = 1
if sp == -1:
	print(0)
else:
	print(o)


n = int(input())
ll = list(map(int, input().split()))
pos = []
for i in range(n):
	if ll[i] == 1:
		pos.append(i)
if len(pos) == 0:
	print(0)
else:
	ans = 1
	for i in range(1, len(pos)):
		ans *= pos[i] - pos[i - 1]
	print(ans)


n = int(input())
data = [int(i) for i in input().split()]
box = []
l = 0
for i in range(n):
	if data[i] == 1:
		box.append(i)
		l += 1
if l:
	ret = 1
	for i in range(l - 1, 0, -1):
		ret *= box[i] - box[i - 1]
	print(ret)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
col = a.count(1)
while len(a) != 0 and a[0] == 0:
	a.pop(0)
while len(a) > 0 and a[-1] == 0:
	a.pop()
ans = []
col = 0
for i in range(len(a)):
	if a[i] == 1:
		ans.append(col)
		col = 0
	if a[i] == 0:
		col += 1
sum = 1
for i in range(len(ans)):
	sum = sum * (ans[i] + 1)
if len(a) == 0:
	sum = 0
print(sum)


n = int(input())
a = list(map(int, input().split()))
z = 0
ans = 0
i = 0
while i < n:
	if a[i] == 1:
		ans = 1
		break
	i += 1
else:
	ans = 0
i += 1
while i < n:
	if a[i] == 1:
		ans *= z + 1
		z = 0
	else:
		z += 1
	i += 1
print(ans)


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)
(n,) = map(int, sys.stdin.readline().split())
cs = list(map(int, sys.stdin.readline().split()))
l = -1
ans = 0
for (i, c) in enumerate(cs):
	if c == 1:
		if l != -1:
			ans *= i - l
		else:
			ans = 1
		l = i
print(ans)


n = int(input())
a = list(map(int, input().split()))
cnt = [0] * (n + 10)
dp = [0] * (n + 10)
dp[0] = 1
for i in range(1, n + 1):
	cnt[i] = cnt[i - 1] + a[i - 1]
for i in range(1, n + 1):
	for j in range(0, i):
		if cnt[i] - cnt[j] == 1:
			dp[i] += dp[j]
print(dp[n])


def solve(arr):
	ls = [i for i in range(len(arr)) if arr[i] == 1]
	ans = 1
	if len(ls) == 0:
		return 0
	else:
		for j in range(1, len(ls)):
			ans *= ls[j] - ls[j - 1]
		return ans
n = int(input())
arr = list(map(int, input().split()))
print(solve(arr))


n = int(input())
l = list(map(int, input().split()))
x = []
t = 1
for (ii, i) in enumerate(l):
	if i == 1:
		x.append(ii)
if not len(x):
	print(0)
	quit()
for i in range(len(x) - 1):
	t *= x[i + 1] - x[i]
print(t)


n = int(input())
A = list(map(int, input().split()))
O = []
for i in range(n):
	if A[i] == 1:
		O.append(i + 1)
if len(O) == 0:
	print(0)
else:
	ans = 1
	for i in range(1, len(O)):
		ans *= O[i] - O[i - 1]
	print(ans)


n = int(input())
s = list(map(int, input().split()))
a = []
b = 1
if s.count(1) == 0:
	print('0')
else:
	for i in range(n):
		if s[i] == 1:
			a.append(i)
	for i in range(1, len(a)):
		b *= a[i] - a[i - 1]
	print(b)


n = int(input())
a = list(map(int, input().split()))
(ans, temp, left) = (1, 1, 0)
for i in a:
	if i == 0:
		temp = temp + 1
	else:
		if left:
			ans = ans * temp
		else:
			left = 1
		temp = 1
if temp == n + 1:
	print(0)
else:
	print(ans)


n = int(input())
v = []
s = input().split()
c = 1
try:
	i = s.index('1')
except:
	i = 0
for b in range(i, n):
	if s[b] == '1':
		v.append(c)
		c = 1
	else:
		c += 1
res = 1
for s in v:
	res *= s
if v == []:
	res = 0
print(res)


n = int(input())
a = list(tuple(map(int, input().split())))
while len(a) > 0 and a[0] == 0:
	a.pop(0)
while len(a) > 0 and a[-1] == 0:
	a.pop()
if len(a) == 0:
	print('0')
else:
	res = 1
	num = 1
	for i in a:
		if i == 0:
			num += 1
		if i == 1:
			res *= num
			num = 1
	print(str(res))


pieces = int(input())
order = list(map(int, input().split()))
first_1 = 0
consec = 1
ways = 1
exist_1 = 0
for (i, piece) in enumerate(order):
	if piece == 1:
		first_1 = i
		exist_1 = 1
		break
if exist_1 == 1:
	for piece in order[first_1:]:
		if piece == 1:
			ways *= consec
			consec = 1
		else:
			consec += 1
	print(ways)
else:
	print('0')


n = int(input())
A = list(map(int, input().split()))
if A.count(1) == 0:
	print(0)
	exit()
i = A.index(1)
c = ans = 1
while i < n:
	if A[i] == 0:
		c += 1
	else:
		ans *= c
		c = 1
	i += 1
print(ans)


n = int(input())
entrada = input()
entrada_str = list(entrada.split(' '))
vetor = list(map(int, entrada_str))
cont = 0
for i in vetor:
	if i == 1:
		cont += 1
if cont == 1:
	print(1)
elif cont == 0:
	print(0)
else:
	resposta = 1
	for i in range(n):
		if vetor[i] == 1:
			cont = 1
			j = i + 1
			while j < n and vetor[j] == 0:
				if j == n - 1:
					cont = 0
				cont += 1
				j += 1
			resposta = resposta * cont
			j -= 1
	print(resposta)


a = int(input())
x = list(map(int, input().split()))
z = []
r = []
for i in range(len(x)):
	if x[i] == 1:
		z.append(i)
for i in range(len(z) - 1):
	r.append(z[i + 1] - z[i])
if len(r) == 0:
	if 1 in x:
		print(1)
	else:
		print(0)
else:
	prod = 1
	for i in range(len(r)):
		prod = prod * r[i]
	print(prod)


n = int(input())
line = ''.join(input().split())
line = line[line.find('1'):]
line = line[:line.rfind('1') + 1]
ans = 0
prev = -1
for i in range(len(line)):
	if line[i] == '1':
		if prev == -1:
			ans = 1
		else:
			ans *= i - prev
		prev = i
print(ans)


n = int(input())
m = 0
a = 1
p = 0
l = list(map(int, input().split()))
for i in range(n):
	if l[i] == 1:
		m += 1
		if m > 0:
			if m > 1:
				a *= i - p
			p = i
print(a if m > 0 else 0)


n = int(input())
a = list(map(int, input().split()))
prev = -1
i = 0
ans = 1
while i < n:
	if a[i] == 1:
		if prev == -1:
			prev = i
		else:
			ans = ans * (i - prev)
			prev = i
	i += 1
if prev == -1:
	print(0)
else:
	print(ans)


n = int(input())
a = [int(x) for x in input().split()]
if a.count(1) == 0:
	print(0)
elif a.count(1) == 1:
	print(1)
else:
	ans = 1
	start = a.index(1)
	try:
		while True:
			next = a.index(1, start + 1)
			ans *= next - start
			start = next
	except:
		pass
	print(ans)


n = int(input())
a = input().split()
p = 1
c = 1
f = 0
for i in a:
	if i == '1':
		p *= c
		c = 1
		f = 1
	elif f:
		c += 1
if f:
	print(p)
else:
	print(0)


input()
s = input().replace(' ', '').strip('0')
print((0, eval('*'.join([str(len(i) + 1) for i in s.split('1')])))[s != ''])


n = input()
n = int(n)
d = input().split(' ')
e = 1
f = 1
try:
	for i in d[d.index('1') + 1:-1]:
		if i == '1':
			f *= e
			e = 1
		else:
			e += 1
	if d[-1] == '1':
		f *= e
	print(f)
except:
	print(0)


n = int(input())
l = list(map(int, input().split()))
l1 = []
c = 0
g = 0
for i in range(n):
	if c == 1 and l[i] == 1:
		l1.append(i + 1 - g)
	if c == 0 and l[i] == 1:
		l1.append(1)
		c = 1
	if c == 0 and l[i] == 0:
		g = g + 1
k = 1
if len(l1) == 0:
	print(0)
elif len(l1) == 1:
	print(1)
else:
	for i in range(len(l1) - 1):
		k = k * abs(l1[i] - l1[i + 1])
	print(k)


n = int(input())
bar = input().split()
count = 1
br = 0
if '1' not in bar:
	print(0)
	exit()
for i in range(0, n):
	if int(bar[i]) == 1:
		for j in range(i + 1, n):
			if int(bar[j]) == 1:
				count *= j - i
				break
print(count)


n = int(input())
a = input()
a = a.replace(' ', '')
a = str(int(a))
(k, r) = (1, 0)
if '1' not in a:
	print(0)
else:
	for i in a:
		if i == '0':
			r += 1
		else:
			k *= r + 1
			r = 0
	print(k)


n = int(input())
L = input().split()
Flag = False
indl = -1
indr = -1
ans = 1
t = 0
for i in range(len(L)):
	if L[i] == '1' and Flag != True:
		indl = i
		Flag = True
	if L[i] == '1':
		indr = i
if indl == -1 and indr == -1:
	print('0')
else:
	for i in range(indl + 1, indr + 1):
		if L[i] == '0':
			t += 1
		else:
			ans = ans * (t + 1)
			t = 0
	print(ans)


n = int(input())
a = list(map(int, input().split()))
(cnt, zero, ans) = (0, 0, 1)
i = 0
k = a.count(1)
while i < n - 1:
	if a[i] == 1:
		for j in range(i + 1, n):
			if a[j] == 1:
				zero = j - i - 1
				ans = ans * (zero + 1)
				i = j - 1
				break
	i += 1
if k == 0:
	print(0)
else:
	print(ans)


n = int(input())
a = [int(i) for i in input().split()]
b = []
for i in range(n):
	if a[i]:
		b.append(i)
p = 1
if b == []:
	print(0)
else:
	for i in range(1, len(b)):
		p *= b[i] - b[i - 1]
	print(p)


n = int(input())
a = [int(x) for x in input().split()]
if 1 in a:
	if a.count(1) == 1:
		print('1')
	else:
		i = a.index(1)
		j = n - a[::-1].index(1)
		a = a[i:j]
		i = 0
		ans = 1
		while i < len(a) - 1:
			j = 1
			i += 1
			while a[i] == 0:
				j += 1
				i += 1
				if i == len(a):
					break
			ans *= j
		print(ans)
else:
	print('0')


x = int(input())
lst = input()
lst = lst.split()
ones = lst.count('1')
if ones == 0:
	print(0)
	exit()
ans = 1
count_ones = 0
for i in range(x):
	if lst[i] == '1':
		count_ones += 1
		if count_ones == ones:
			print(ans)
			exit()
		temp = lst.index('1', i + 1)
		zeros = temp - i
		ans = ans * zeros


n = int(input())
a = [int(i) for i in input().split()]
prev = -1
res = 0
for i in range(n):
	if a[i] == 1:
		if prev == -1:
			res = 1
		else:
			res *= i - prev
		prev = i
print(res)


n = int(input())
s = ''.join(input().split()).split('1')
if len(s) == 1:
	(print(0), exit(0))
s = s[1:-1]
ans = 1
for i in s:
	ans *= len(i) + 1
print(ans)


from functools import reduce
n = int(input())
string = input().replace(' ', '')
vetor = []
for (i, num) in enumerate(string):
	if num == '1':
		vetor.append(i)
if len(vetor) == 0:
	print(0)
elif len(vetor) == 1:
	print(1)
else:
	new_vetor = []
	for (x, y) in zip(vetor, vetor[1:]):
		new_vetor.append(abs(x - y) - 1)
	new_vetor = list(map(lambda x: x + 1, new_vetor))
	ans = 1
	for num in new_vetor:
		ans *= num
	print(ans)


n = int(input())
a = list(map(int, input().split()))
ans = 0
if a.count(1) == 1:
	ans = 1
elif a.count(1) > 1:
	ans = 1
	index_one = []
	for i in range(n):
		if a[i] == 1:
			index_one.append(i)
	for i in range(len(index_one) - 1):
		ans *= index_one[i + 1] - index_one[i]
print(ans)


n = int(input())
a = list(map(int, input().split()))
b = [1] * 110
j = 0
ans = 0
for i in range(len(a)):
	if a[i] == 1:
		j += 1
		ans = 1
	else:
		b[j] += 1
for i in range(1, j):
	ans *= b[i]
print(ans)
import time, sys
sys.stderr.write('{0:.3f} ms\n'.format(time.clock() * 1000))


def solve(n, nuts):
	try:
		i = nuts.index('1')
	except:
		return 0
	ri = nuts.rindex('1')
	if i == ri:
		return 1
	res = 1
	start = i
	cur = start + 1
	while cur <= ri:
		if nuts[cur] == '1':
			res *= cur - start
			start = cur
			cur = start + 1
		else:
			cur += 1
	return res

def __starting_point():
	n = int(input())
	nuts = ''.join(input().split())
	print(solve(n, nuts))
__starting_point()


import sys
input = sys.stdin.readline
n = int(input())
choco = list(map(int, input().split()))
ones_index = []
for i in range(n):
	if choco[i]:
		ones_index.append(i)
if len(ones_index) == 0:
	print(0)
elif len(ones_index) == 1:
	print(1)
else:
	res = 1
	for i in range(len(ones_index) - 1):
		res *= ones_index[i + 1] - ones_index[i]
	print(res)


from functools import reduce
n = int(input())
line = list(map(int, input().split()))
rest = list()
for i in range(n):
	if line[i] == 1:
		rest.append(i + 1)
size = len(rest)
if size < 2:
	print(size)
else:
	for i in range(1, size):
		rest[i - 1] = rest[i] - rest[i - 1]
	print(reduce(lambda x, y: x * y, rest[:-1]))


n = int(input())
l = list(map(int, input().split()))
z = []
count = -1
for i in range(n):
	if l[i] == 1:
		z.append(i + 1)
if len(z) == 0:
	print(0)
elif len(z) == 1 or len(z) == n:
	print(1)
else:
	pro = 1
	for i in range(len(z) - 1):
		pro = pro * abs(z[i] - z[i + 1])
	print(pro)


n = input()
a = input()
s = 1
if a.count('1') == 0:
	s = 0
else:
	prev = a.find('1')
	for i in range(0, len(a), 2):
		if prev != i and a[i] == '1':
			s *= (i - prev) // 2
			prev = i
print(s)


import sys
n = int(input())
a = list(map(int, input().split()))
if a.count(1) == 0:
	print(0)
	sys.exit(0)
while a[n - 1] == 0:
	a.pop()
	n -= 1
a = a[::-1]
while a[n - 1] == 0:
	a.pop()
	n -= 1
pr = []
cnt = 0
for i in range(n - 1):
	if a[i] == a[i + 1] == 0:
		cnt += 1
	elif a[i] != a[i + 1] == 0:
		cnt = 1
	elif a[i] != a[i + 1] == 1:
		pr.append(cnt)
s = 1
for elem in pr:
	s *= elem + 1
print(s)


n = int(input())
L = [int(s) for s in input().split()]

def f(l):
	if 1 not in l:
		return 0
	if l.count(1) == 1:
		return 1
	k = l.index(1) + 1
	c = 1
	while k < len(l) - 1 and l[k] != 1:
		k += 1
		c += 1
	return c * f(l[k:])
print(f(L))


import os
import sys
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
n = Int()
a = array()
i = 0
while i < n and (not a[i]):
	i += 1
a = a[i:]
a = a[::-1]
i = 0
while i < len(a) and (not a[i]):
	i += 1
a = a[i:]
ans = 0
if len(a):
	ans = 1
last = 0
for i in range(1, len(a)):
	if a[i]:
		ans *= i - last
		last = i
print(ans)


n = int(input())
lst = [int(i) for i in input().split()]
if lst.count(1) == 1:
	print(1)
	exit(0)
if lst.count(1) == 0:
	print(0)
	exit(0)
cnt = 0
prev = None
ans = 1
for i in range(n):
	if lst[i] == 1:
		cnt += 1
		if cnt > 1:
			ans *= i - prev
		prev = i
print(ans)


import sys
n = int(input())
a = [int(x) for x in input().split()]
try:
	while a[-1] != 1:
		a.pop()
	index = 0
except IndexError:
	print(0)
	sys.exit(0)
while a[index] != 1:
	index += 1
a = a[index + 1:]
(cur, count) = (0, 1)
for c in a:
	cur += 1
	if c == 1:
		count *= cur
		cur = 0
print(count)


n = int(input())
a = list(map(int, input().split(' ')))
qqq = False
k = 0
ans = 1
for i in range(len(a)):
	if a[i] == 1:
		qqq = True
		if k > 0:
			ans = ans * (k + 1)
			k = 0
	elif qqq == True:
		k = k + 1
if qqq == True:
	print(ans)
else:
	print('0')


n = int(input())
chocolate = list(map(int, input().split(' ')))
res = 1
flag = 0
stack = []
for i in range(n):
	if chocolate[i] == 1:
		flag = 1
		stack.append(i)
if len(stack) > 1:
	for i in range(len(stack) - 1):
		res = res * abs(stack[i + 1] - stack[i])
else:
	res = 1
if flag:
	print(res)
else:
	print(0)


def main():
	n = int(input())
	l = list(map(int, input().split()))
	index_1 = []
	for i in range(n):
		if l[i] == 1:
			index_1.append(i)
	if len(index_1) == 0:
		return 0
	if len(index_1) == 1:
		return 1
	else:
		result = 1
		temp = index_1[0]
		for i in range(1, len(index_1)):
			result *= index_1[i] - temp
			temp = index_1[i]
		return result
print(main())


n = int(input())
sp = list(map(int, input().split()))
if sp.count(1) == 0:
	print(0)
else:
	kol = 1
	spp = sp[:]
	for i in range(n):
		if sp[i] == 1:
			spp[i] = 0
			try:
				kol *= spp.index(1) - i
			except:
				continue
	print(kol)


x = int(input())
y = list(map(int, input().split(' ')))
if y == [0] * x:
	print(0)
	quit()
for i in range(x):
	if y[i] == 1:
		y = y[i:]
		break
y.reverse()
for i in range(len(y)):
	if y[i] == 1:
		y = y[i:]
		break
y.reverse()
l = []
ct = 0
for i in y:
	if i == 0:
		ct += 1
	if i == 1 and ct != 0:
		l.append(ct)
		ct = 0
k = 1
for i in l:
	k *= i + 1
print(k)


n = int(input())
a = list(map(int, input().split()))
num = a.count(1)
if num == n:
	print(1)
elif num == 0:
	print(0)
else:
	c = 1
	i = a.index(1)
	last_1 = a[::-1].index(1)
	last_1 = n - last_1
	while i < last_1 - 1:
		j = i + 1
		while j < last_1 and a[j] == 0:
			j += 1
		c *= j - i
		i = j
	print(c)


pieces = int(input())
nuts = list(map(int, input().split()))
nutsIndex = []
for i in range(pieces):
	if nuts[i] == 1:
		nutsIndex.append(i)
if len(nutsIndex) == 0:
	print(0)
elif len(nutsIndex) == 1:
	print(1)
else:
	answer = 1
	for i in range(1, len(nutsIndex)):
		answer *= nutsIndex[i] - nutsIndex[i - 1]
	print(answer)


a = int(input())
ls = list(map(int, input().split()))
x = 0
while x < a:
	if ls[x] == 0:
		x = x + 1
	else:
		break
su = 1
ml = 1
if x == a:
	print('0')
	quit()
while x < a:
	if ls[x] == 1:
		su = su * ml
		ml = 1
	else:
		ml = ml + 1
	x = x + 1
print(su)


from operator import mul
from functools import reduce

class CodeforcesTask617BSolution:

	def __init__(self):
		self.result = ''
		self.chocolate = []

	def read_input(self):
		input()
		self.chocolate = ''.join(input().split(' '))

	def process_task(self):
		result = 1
		if self.chocolate.count('1') > 1:
			usefull_bar = self.chocolate.split('1', 1)[1][::-1].split('1', 1)[1][::-1]
			ways = [len(x) + 1 for x in usefull_bar.split('1')]
			result = reduce(mul, ways, 1)
		elif not self.chocolate.count('1'):
			result = 0
		self.result = str(result)

	def get_result(self):
		return self.result
Solution = CodeforcesTask617BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


n = int(input())
ls = list(map(int, input().split()))
answer = 0
i = 0
one = False
while i < n:
	if ls[i] == 1:
		j = i + 1
		found = False
		while j < n:
			if ls[j] == 1:
				found = True
				break
			j += 1
		if found:
			zeroes = j - i - 1
			if not answer:
				answer += zeroes + 1
			else:
				answer *= zeroes + 1
		elif not one:
			answer += 1
		one = True
		i = j
	else:
		i += 1
print(answer)


n = int(input())
s = [int(i) for i in input().split()]
l = []
for i in range(n):
	if s[i] == 1:
		l.append(i)
k = 1
for i in range(len(l) - 1):
	k = k * (l[i + 1] - l[i])
if len(l) == 0:
	print(0)
else:
	print(k)


input()
reduced_chocolate = input()[::2].strip('0')
if reduced_chocolate:
	(ways, zeros) = (1, 0)
	for piece in reduced_chocolate:
		if piece == '0':
			zeros += 1
		elif zeros:
			(ways, zeros) = (ways * (zeros + 1), 0)
	print(ways)
else:
	print(0)


n = int(input())
a = list(map(int, input().split()))
if max(a) == 0:
	print(0)
	return
ans = 1
started = False
count = 1
for i in range(n):
	if a[i] == 1 and (not started):
		started = True
		continue
	if started and a[i] == 0:
		count += 1
	if started and a[i] == 1:
		ans *= count
		count = 1
print(ans)


n = input()
a = input().split()
(t, d, x) = (1, 0, 1)
for i in range(len(a)):
	if a[i] == '0':
		x += d
	else:
		t *= x
		(d, x) = (1, 1)
print(t * d)


n = int(input())
a = list(map(str, input().split()))
if set(a) == {'0'}:
	print(0)
else:
	a = ''.join(a).strip('0')
	zero = a.count('0')
	w = []
	c = 0
	for i in range(len(a) - 1):
		if a[i] == '0' and a[i + 1] == '0':
			c += 1
		elif a[i] == '0' and a[i + 1] == '1':
			c += 1
			w.append(c)
			c = 0
	ans = 1
	for i in w:
		ans *= i + 1
	print(ans)


a = int(input())
b = input()
bList = list(map(int, b.split()))
counter = 0
newCounter = 0
j = 0
counter = 0
x = 1
k = 1
y = 0
while j < len(bList):
	if bList[j] == 1:
		counter = 1
		while j + 1 < len(bList):
			if bList[j + 1] == 0:
				counter += 1
			else:
				x *= counter
				break
			j += 1
	else:
		y += 1
	j += 1
if y == len(bList):
	x = 0
print(x)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from itertools import *
n = ii()
l = ''.join((str(i) for i in il()))
c = 1
for (i, j) in groupby(l.strip('0')):
	if i == '0':
		c *= len(list(j)) + 1
print(c if l.count('1') != 0 else 0)


import math
n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print(0 if a[0] == 0 else 1)
	exit()
if len(set(a)) == 1 and a[0] == 0:
	print(0)
	exit()
b = [0]
temp = 0
for i in range(n):
	if a[i] == 1:
		j = i
		while j < n - 1 and a[j + 1] != 1:
			temp += 1
			j += 1
			i += 1
		b.append(temp + 1)
		temp = 0
if a[n - 1] == 0:
	b.pop()
ans = 1
for x in b:
	ans *= max(x, 1)
print(ans)


n = int(input())
x = [int(q) for q in input().split()]
c = []
for i in range(n):
	if x[i] == 1:
		c.append(i)
if len(c) == 0:
	print(0)
else:
	d = []
	for i in range(1, len(c)):
		d.append(c[i] - c[i - 1])
	ans = 1
	for i in range(len(d)):
		ans *= d[i]
	print(ans)


n = int(input())
ch = [int(t) for t in input().split()]
if ch.count(1) == 0:
	print(0)
	exit(0)
ans = 1
space = 0
first = True
for p in ch:
	if p == 0:
		space += 1
	elif first:
		first = False
		space = 1
	else:
		ans *= space
		space = 1
print(ans)


n = int(input())
bar = [int(x) for x in input().split()]
for (i, thing) in reversed(list(enumerate(bar))):
	if thing == 0:
		del bar[i]
	else:
		break
firstone = -1
for (i, thing) in enumerate(bar):
	if thing == 1:
		firstone = i
		break
bar = bar[firstone:]
cracks = 1
zeros = 0
for barette in bar:
	if barette == 1:
		cracks *= zeros + 1
		zeros = 0
		continue
	zeros += 1
if firstone == -1:
	print('0')
else:
	print(cracks)


def arr_inp():
	return [int(x) for x in stdin.readline().split()]
from sys import *
(n, a) = (int(input()), arr_inp())
(beg, end) = (0, n - 1)
if max(a) == 0:
	exit(print(0))
elif min(a) == 1 or a.count(1) == 1:
	exit(print(1))
for i in range(n):
	if a[i]:
		break
	else:
		beg += 1
for i in range(n - 1, beg - 1, -1):
	if a[i]:
		break
	else:
		end -= 1
(flag, out, ans) = (1, 0, 1)
for i in range(beg, end + 1):
	if a[i] and flag:
		flag = 0
		if out:
			ans *= out
		out = 0
	elif a[i] == 0:
		if flag == 0:
			out += 1
		flag = 1
		out += 1
print(ans)


n = int(input())
c = list(map(int, input().split()))
a = []
k = -1
for i in range(n):
	if c[i] == 1:
		if k != -1:
			a.append(k)
		k = 1
	elif k != -1:
		k += 1
else:
	if k != -1:
		a.append(k)
if a != []:
	l = 1
	for i in range(0, len(a) - 1):
		l *= a[i]
	print(l)
else:
	print(0)


import sys
input = sys.stdin.readline
read_tuple = lambda _type: map(_type, input().split(' '))
from collections import Counter

def solve():
	n = int(input())
	a = list(read_tuple(int))
	if sum(a) == 0:
		return 0
	if sum(a) == 1:
		return 1
	indeces = []
	for i in range(n):
		if a[i] == 1:
			indeces.append(i)
	diffs = []
	for i in range(1, len(indeces)):
		diffs.append(indeces[i] - indeces[i - 1])
	ans = 1
	for d in diffs:
		ans *= d
	return ans
print(solve())


import functools

def f():
	input()
	a = input().replace(' ', '').strip('0')
	print(functools.reduce(lambda x, y: x * y, map(lambda x: len(x) + 1, a.split('1'))) if len(a) else 0)
f()


n = int(input())
data = list(map(int, input().split()))
data1 = []
ans = 1
for i in range(n):
	if data[i]:
		data1.append(i)
for i in range(1, len(data1)):
	ans *= data1[i] - data1[i - 1]
if not sum(data):
	print(0)
else:
	print(ans)


n = int(input())
pieces = [int(t) for t in input().split()]
nutcount = 0
curways = 1
ways = []
for (i, piece) in enumerate(pieces):
	if piece:
		ways.append(curways)
		curways = 1
		nutcount += 1
	elif nutcount:
		curways += 1
result = 1
for w in ways:
	result *= w
if not ways:
	result = 0
print(result)


from sys import stdin

def ii():
	return int(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline()
n = ii()
a = li()
p = 0
if 1 in a:
	p = 1
	s = f = a.index(1)
	l = n - a[::-1].index(1)
	for i in range(f + 1, l):
		if a[i]:
			p *= i - s
			s = i
print(p)


x = int(input())
(*li,) = map(int, input().split())
cnt = 1
ans = 1
if 1 not in li:
	print(0)
	exit()
a = li.index(1)
for i in range(a + 1, x):
	if li[i] == 1:
		ans *= cnt
		cnt = 1
	else:
		cnt += 1
print(ans)


n = int(input())
a = list(map(int, input().split()))
pre = -1
res = 1
fl = False
for i in range(n):
	if a[i] is 1:
		if pre is not -1:
			res *= i - pre
		pre = i
		fl = True
if fl is False:
	print(0)
else:
	print(res)


n = int(input())
input1 = list(map(int, input().split()))
(a, b, c, d) = (0, 0, 1, 0)
if 1 in input1:
	b = input1.index(1)
for x in range(0, n):
	if input1[x] == 1:
		d += 1
		if x != input1.index(1):
			b = a
		a = x
		if x != input1.index(1):
			c *= a - b
if d != 0:
	print(c)
else:
	print(0)


n = int(input())
l = [int(i) for i in input().split()]
ones = l.count(1)
i = 0
if 1 in l:
	i = 1
c = 1
while i < ones:
	ind = l.index(1)
	i += 1
	l.pop(ind)
	nind = l.index(1)
	c *= nind - ind + 1
if i == 1 or i == 0:
	print(i)
else:
	print(c)


_ = int(input())
choc = list(map(int, list(input().split())))
if 1 not in choc:
	print(0)
else:
	while choc[0] != 1:
		choc.pop(0)
	while choc[-1] != 1:
		choc.pop(-1)
	pstns = []
	count = 0
	for sq in choc:
		if sq == 1:
			pstns.append(count)
			count = 0
		else:
			count += 1
	ans = 1
	for n in pstns:
		if n != 0:
			ans = ans * (n + 1)
	print(ans)


n = int(input())
nuts = input().split()
zeroes_num = 1
any_nut = False
ans = 1
for bit in nuts:
	if bit == '0':
		if any_nut:
			zeroes_num += 1
	else:
		any_nut = True
		ans *= zeroes_num
		zeroes_num = 1
print(ans if any_nut else 0)


n = int(input())
s = list(map(int, input().split()))
ttt = False
attt = 0
tmp = 0
ans = 1
for i in s:
	if i == 1:
		if ttt:
			tmp += 1
			ans *= tmp
		tmp = 0
		ttt = True
		attt += 1
	else:
		tmp += 1
if attt >= 1:
	print(ans)
else:
	print(0)


input()
pieces = list(map(int, input().split()))
N = len(pieces)
oneIndexes = [i for (i, e) in enumerate(pieces) if e == 1]
if len(oneIndexes) == 0:
	print(0)
else:
	ans = 1
	for i in range(len(oneIndexes) - 1):
		ans *= oneIndexes[i + 1] - oneIndexes[i]
	print(ans)


cp = int(input())
c = [int(i) for i in input().split()]
if c.count(1) == 1 or c.count(1) == 0:
	print(c.count(1))
else:
	i = c.index(1) + 1
	count = 1
	pr = 1
	while i < cp:
		if c[i] == 0:
			count += 1
			i += 1
		else:
			pr *= count
			i += 1
			count = 1
	print(pr)


input()
c = ' ' + input() + ' '
s = 1
for x in c.split('1')[1:-1]:
	s *= x.count('0') + 1
print((c.find('1') > -1) * s)


n = int(input())
arr = list(map(int, input().split()))
if arr.count(1) == 0:
	print(0)
else:
	flag = 0
	ans = 1
	zeros = 0
	for i in arr:
		if i:
			if not flag:
				flag = 1
			else:
				ans *= zeros + 1
			zeros = 0
		else:
			zeros += 1
	print(ans)


n = int(input())
lst = list(map(int, input().split()))
ans = 1
cnt = 0
if 1 in lst:
	p = lst.index(1)
	for i in range(p, n):
		if lst[i] == 1:
			if cnt != 0:
				ans *= cnt
				cnt = 0
		cnt += 1
	print(ans)
else:
	print(0)


n = int(input())
l = list(map(int, input().split()))
pos1 = []
for i in range(n):
	if l[i] == 1:
		pos1.append(i)
if len(pos1) >= 1:
	ans = 1
	for i in range(1, len(pos1)):
		ans *= pos1[i] - pos1[i - 1]
	print(ans)
else:
	print(0)


input()
(*a,) = map(int, input().split())
if set(a) == set([0]):
	print(0)
else:
	i = 0
	while a[i] == 0:
		i += 1
	i += 1
	b = []
	c = 1
	while i < len(a):
		if a[i] == 0:
			c += 1
		else:
			b += [c]
			c = 1
		i += 1
	d = 1
	for i in b:
		d *= i
	print(d)


def ways(a):
	w = 0
	p = None
	for (i, ai) in enumerate(a):
		if ai == '1':
			if p is None:
				w = 1
			else:
				w *= i - p
			p = i
	return w
n = int(input())
a = input().split()
assert len(a) == n
print(ways(a))


n = int(input())
list1 = list(map(int, input().split()))
start = False
j = 1
ans = 1
for i in range(0, len(list1)):
	if list1[i] == 1:
		start = True
		ans = ans * j
		p = i
		j = 1
	elif list1[i] == 0 and start == True:
		j += 1
if start == False:
	print('0')
else:
	print(ans)


input()
L = [int(e) for e in input().split(' ')]
if not sum(L):
	print(0)
	exit()
while not L[-1]:
	L.pop()
while not L[0]:
	L.remove(0)
rez = 1
multiplier = 1
L.remove(1)
while L:
	multiplier = L[:L.index(1)].count(0) + 1
	rez *= multiplier
	while L and (not L[0]):
		L.remove(0)
	L.remove(1)
print(rez)


n = int(input())
a = list(map(int, input().split()))
indexes = []
for i in range(n):
	if a[i] == 1:
		indexes.append(i)
ans = 1
n = len(indexes)
for i in range(n - 1):
	ans *= indexes[i + 1] - indexes[i]
if n == 0:
	ans = 0
print(ans)


x = int(input())
n = input().split()
p = 0
l = []
f = 0
for i in range(x):
	if n[i] == '1':
		if p > 0:
			l.append(i - f)
		else:
			p = 1
		f = i
if len(l) == 0 and p == 0:
	print(0)
else:
	k = 1
	for i in l:
		k *= i
	print(k)


from math import factorial

def ncr(n, r):
	return factorial(n) / factorial(r) / factorial(n - r)
n = int(input())
bar = list(input().split())
nuts = bar.count('1')
if nuts <= 1:
	print(nuts)
	exit()
total = 1
while bar:
	start = bar.index('1')
	if '1' not in bar[start + 1:]:
		break
	next_nut = start + bar[start + 1:].index('1') + 1
	spaces = next_nut - start
	total *= ncr(spaces, 1)
	bar = bar[next_nut:]
print(int(total))


n = int(input())
arr_a = input().split()
arr_a = [int(a) for a in arr_a]
result = 0
agora = 0
ct = 0
j = 0
for i in range(0, n):
	if arr_a[i] == 1:
		ct += 1
		if ct == 1:
			result = 1
		else:
			result *= i - j
		j = i
print(result)


def resolve():
	n = input()
	array = input().split()
	result = 1
	index = -1
	for i in range(0, len(array)):
		if array[i] == '1':
			index = i
			break
	if index == -1:
		print(0)
		return
	ult = index
	for i in range(1 + ult, len(array)):
		if array[i] == '1':
			result = result * (i - ult)
			ult = i
	print(result)
resolve()


n = int(input())
a = list(map(int, input().split()))
ones = []
for (i, x) in enumerate(a):
	if x == 1:
		ones.append(i)
ans = 1
for i in range(1, len(ones)):
	ans *= ones[i] - ones[i - 1]
if len(ones) == 0:
	print(0)
else:
	print(ans)


n = int(input())
arr = list(map(int, input().split()))
result = 1
i = 0
flag = False
while i < n:
	if arr[i] == 1:
		flag = True
		count = 0
		j = i + 1
		while j < n and arr[j] == 0:
			count += 1
			j += 1
		if j < n and count != 0:
			result *= count + 1
		i = j
	else:
		i += 1
if not flag:
	result = 0
print(result)


n = int(input())
zero = []
t = 0
a = input().strip().split()
for (index, item) in enumerate(a):
	a[index] = int(item)
if sum(a) == 1:
	ans = 1
elif sum(a) == 0:
	ans = 0
else:
	i = 0
	while a[i] != 1:
		del a[i]
	j = len(a) - 1
	while a[j] != 1:
		del a[j]
		j -= 1
	for i in range(len(a)):
		if a[i] == 1:
			if t != 0:
				zero.append(t)
				t = 0
		else:
			t += 1
	if zero == []:
		ans = 1
	else:
		ans = zero[0] + 1
		for i in range(1, len(zero)):
			ans = ans * (zero[i] + 1)
print(ans)


n = int(input())
arr = [int(x) for x in input().split()]
resp = 1
numZero = 0
numOne = 0
for i in range(n):
	if numOne > 0 and arr[i] == 0:
		numZero += 1
	elif arr[i] == 1:
		numOne += 1
		resp *= numZero + 1
		numZero = 0
if numOne == 0:
	print(0)
else:
	print(resp)


n = int(input())
a = list(map(int, input().split()))
try:
	p = a.index(1)
	c = 1
	z = 1
	for i in a[p + 1:]:
		if i == 1:
			c *= z
			z = 1
		else:
			z += 1
	print(c)
except ValueError:
	print(0)


n = input()
arr = input().split()
s = False
cnt = []
it = 0
zero = 0
for x in arr:
	if x == '1':
		if s:
			cnt.append(it)
			it = 1
		else:
			s = True
			it = it + 1
	else:
		zero = zero + 1
		if s:
			it = it + 1
if len(arr) == zero:
	print(0)
else:
	ans = 1
	for x in cnt:
		ans = ans * x
	print(ans)


n = int(input())
a = list(map(int, input().split()))
if a.count(1) == 1:
	print(1)
elif a.count(1) == 0:
	print(0)
else:
	s = n - 1
	while s > -1 and a[s] == 0:
		s -= 1
	i = a.index(1) + 1
	an = 1
	while i < s:
		j = i
		c = 0
		while j < s and a[j] == 0:
			c += 1
			j += 1
		i = j + 1
		an *= c + 1
	print(an)


n = int(input())
row = [i for i in input().split()]
zero = False
if not '1' in row:
	print(0)
	zero = True
else:
	answer = 1
	nutpos = row.index('1')
	row = row[nutpos + 1:]
	while '1' in row:
		nutpos = row.index('1')
		answer *= nutpos + 1
		row = row[nutpos + 1:]
if zero == False:
	print(answer)


a = int(input())
i = 0
w = []
k = input().split()
for i in range(a):
	k[i] = int(k[i])
i = 0
r = 1
n = 0
while i < a:
	if k[i] == 1:
		w.append(r)
		r = 1
		n = n + 1
	if k[i] == 0:
		r = r + 1
	i = i + 1
i = 1
res = 1
if n > 1:
	while i < n:
		res = res * w[i]
		i = i + 1
	print(res)
if n == 1:
	print(1)
if n == 0:
	print(0)


n = int(input())
prev = -1
ans = 1
count = 1
for x in input().split():
	if int(x) == 1:
		if prev != -1:
			ans *= count - prev
		prev = count
	count += 1
if prev == -1:
	print('0')
else:
	print(ans)


def main():
	_ = int(input())
	bar = input()
	if '1' not in bar:
		print(0)
		exit()
	bar = bar.replace(' ', '')
	start = 1 if bar[0] == '0' else 0
	end = 1 if bar[-1] == '0' else 0
	seq = [c for c in bar.split('1') if len(c) > 0]
	zeros = [len(seq[i]) for i in range(start, len(seq) - end)]
	ans = 1
	for e in zeros:
		ans *= e + 1
	print(ans)
main()


import sys
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
for _ in range(1):
	n = int(input())
	l = list(map(int, input().split()))
	if l.count(1) <= 1:
		print(l.count(1))
	else:
		s = ''.join((str(i) for i in l))
		s = s.split('1')
		s = s[1:-1]
		ans = 1
		for i in range(len(s)):
			ans = ans * (len(s[i]) + 1)
		print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	a = LI()
	if 1 not in a:
		return 0
	t = []
	k = 0
	f = 0
	for c in a:
		if c == 1:
			if f:
				t.append(k)
			k = 0
			f = 1
		else:
			k += 1
	r = 1
	for c in t:
		r *= c + 1
	return r
print(main())


n = int(input())
l = list(map(int, input().split(' ')))
one_counter = l.count(1)
zero_counter = l.count(0)
ans = 1
if not one_counter:
	ans = 0
elif one_counter == 1:
	ans = 1
else:
	indexes = [i for i in range(n) if l[i] == 1]
	for i in range(1, len(indexes)):
		ans *= indexes[i] - indexes[i - 1]
print(ans)


n = int(input())
arr = [c for c in input().split()]
s1 = len(arr)
s2 = 0
for i in range(len(arr)):
	if arr[i] == '1':
		s1 = min(s1, i)
		s2 = max(s2, i)
t = 1
res = 1
for i in range(s1, s2 + 1):
	if arr[i] == '1':
		res *= t
		t = 1
	else:
		t += 1
if s2 < s1:
	res = 0
print(res)


n = int(input())
a = input().split()
ans = 1
last = -1
for i in range(n):
	x = int(a[i])
	if x == 1:
		if last != -1:
			ans *= i - last
		last = i
print(0 if last == -1 else ans)


q = int(input())
w = list(map(int, input().split()))
for i in range(q):
	if w[i] == 1:
		w = w[i:]
		break
w = w[::-1]
for i in range(q):
	if w[i] == 1:
		w = w[i:]
		break
r = []
t = 0
for i in w:
	if i == 1:
		r.append(t)
		t = 0
	if i == 0:
		t += 1
r = r[1:]
y = 1
for i in r:
	y *= i + 1
if w.count(1) == 0:
	print(0)
else:
	print(y)


n = int(input())
l = list(map(int, input().split()))
res = 1
last = -1
for i in range(n):
	if l[i] == 1:
		if last != -1:
			res = res * (i - last)
		last = i
if last == -1:
	print(0)
else:
	print(res)


n = int(input())
s = ''.join(input().split())
lis = [i for (i, ltr) in enumerate(s) if ltr == '1']
res = 1
if not lis:
	print(0)
else:
	for i in range(len(lis) - 1):
		res *= lis[i + 1] - lis[i]
	print(res)


n = int(input())
l = list(map(int, input().split()))
from collections import Counter
c = dict(Counter(l))
if 1 in c.keys():
	if c[1] == 1:
		print(1)
	elif c[1] > 1:
		start = False
		count = 0
		possible = []
		for i in l:
			if i == 1 and start == False:
				start = True
			elif i == 1 and start == True:
				possible.append(count)
				count = 0
			elif i == 0 and start == True:
				count += 1
		result = 1
		for i in possible:
			result = result * (i + 1)
		print(result)
elif 1 not in c.keys():
	print(0)


def solve(n, arr):
	ans = arr.count(1)
	if ans == 0:
		print(0)
	else:
		res = 1
		for i in range(n):
			if arr[i] == 1:
				for j in range(i + 1, n):
					if arr[j] == 1:
						res *= j - i
						break
		print(res)

def run():
	n = int(input())
	arr = list(map(int, input().split()))
	solve(n, arr)
run()


tablets = int(input())
bar = input().split()
possibilidades = 1
temUm = False
p1 = 0
p2 = 0
if tablets == 1 and bar[0] == '1':
	print(1)
elif tablets == 1 and bar[0] == '0':
	print(0)
else:
	while p1 < tablets and p2 < tablets:
		while p1 < tablets and bar[p1] != '1':
			p1 += 1
		if p1 < tablets and bar[p1] == '1':
			temUm = True
		p2 = p1 + 1
		while p2 < tablets and bar[p2] != '1':
			p2 += 1
		if p2 < tablets and bar[p2] == '1':
			possibilidades *= p2 - p1
			p1 = p2
			p2 = p2 + 1
	if temUm:
		print(possibilidades)
	else:
		print(0)