while True:
try:
n = int(input())
mList = list(map(int, input().split()))
xList = list(map(int, input().split()))
lst = []
for i in zip(mList, xList):
lst += [i[0]] * i[1]
weights = {0}
for i in lst:
for j in list(weights):
weights.add(i+j)
print(len(weights))
except:
break