while True:
try:
n=int(input())
li1=list(map(int,input().split()))
li2=list(map(int,input().split()))
# print (li2)
fa=[]
for i in range(n):
for j in range(li2[i]):
fa.append(li1[i])
wei={0,}#重量集合初始化
for item in fa:
for ite in list(wei):
wei.add(item+ite)
print(len(wei))
except:
break