while True:
    try:
        n = int(input())
        m = input().split()
        x = input().split()
        mx = [] # 存储所有砝码的砝码,如案例输入的mx = [1,1,2]
        l = {0} # 存储砝码可以表示的值,初始化为{0}
        # 生成mx
        for i in range(n):
            mx.extend([int(m[i])] * int(x[i]))
        # 生成l,每次给砝码生成的值都加一个新的砝码
        for i in mx:
            l = l.union({i + j for j in l})
        print(len(l))
    except:
        break