while True:
try:
data1 = int(input())
data2 = list(map(int,input().split()))
data3 = list(map(int,input().split()))
#存储所有的砝码
list1 = []
for m in range(len(data2)):
for n in range(data3[m]):
list1.append(data2[m])
list2 = [0]
temp = []
for word1 in list1:
temp = set(list2)
for word2 in temp:
list2.append(word1+word2)
print(len(set(list2)))
except:
break