import sys i = int(sys.stdin.readline()) m = list(map(int,sys.stdin.readline().split())) n = list(map(int,sys.stdin.readline().split()))
构造全列表
weight = [m[i] for i in range(len(m)) for _ in range(n[i]) ] weight_temp =[0]
while len(weight)>0: w = weight.pop() weight_temp = list(set(weight_temp+[i+w for i in weight_temp]))
print(len(weight_temp))