n = int(input()) m = list(map(int, input().strip().split(" "))) x = list(map(int, input().strip().split(" "))) s = set() s.add(0) for i in range(n): for num in s.copy(): for j in range(x[i]): num += m[i] s.add(num) print(len(s))