集合

# 输入
n = int(input())
weight = list(map(int,input().split()))
weightNum = list(map(int,input().split()))
# 整合
arr = []
for i in range(n):
    for j in range(weightNum[i]):
        arr.append(weight[i])
# 所有组合情况
res = {0}
for i in arr:
    for j in list(res):
        # 集合去重
        res.add(i+j)
print(len(res))