import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 有多少种砝码
int n = sc.nextInt();
sc.nextLine();
// 每种砝码的重量
String line2 = sc.nextLine();
List<Integer> mList = Arrays.asList(line2.split(" ")).stream().map(Integer::valueOf).collect(Collectors.toList());
// 每种砝码的数量
String line3 = sc.nextLine();
List<Integer> xList = Arrays.asList(line3.split(" ")).stream().map(Integer::valueOf).collect(Collectors.toList());
System.out.println(chengfama(n, mList, xList));
}
private static int chengfama(int n, List<Integer> mList, List<Integer> xList) {
Set<Integer> rSet = new HashSet<Integer>();
rSet.add(0);
for (int i = 0; i < n; i++) {
int m = mList.get(i);
int x = xList.get(i);
for (int j = 0; j < x; j++) {
Set<Integer> tempSet = new HashSet<>(rSet);
for (Integer w : tempSet) {
rSet.add(w + m);
}
}
}
return rSet.size();
}
}