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: interview

Starter code:

Solutions:
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 = ''.join(input().split())

A = A.split('1')
if len(A) == 1:
    print(0)
    return
A = A[1:-1]
answer = 1
for x in A:
    answer *= len(x) + 1

print(answer)


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)


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())
choco = [int(x) for x in input().split()]
if all(c == 0 for c in choco):
    print(0)
    return
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 = 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())
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())
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)

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

print(ans if last != -1 else 0)


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())
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)

#!/usr/bin/env python3
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())
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, 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)

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time

#   = input()
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()
#print(finish - start)


#!/usr/bin/env python3

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)

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())
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())
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)


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()

3

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))


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


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
    else:
        if isone:
            cur += 1
if isone:
    print(ans)
else:
    print(0)
    
    


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)


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)