import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
int n = in.nextInt();
int[] weightArr = new int[n];
for (int i = 0; i < n; i++) {
weightArr[i] = in.nextInt();
}
in.nextLine();
List<Integer> weightList = new ArrayList<>();
for (int i = 0; i < n; i++) {
int count = in.nextInt();
for (int j = 0; j < count; j++) {
weightList.add(weightArr[i]);
}
}
in.nextLine();
Main main = new Main();
System.out.println(main.getWeightCount(weightList));
}
public int getWeightCount(List<Integer> weightList) {
Set<Integer> weightSet = new HashSet<>();
weightSet.add(0);
for (Integer integer : weightList) {
Set<Integer> currentSet = new HashSet<>(weightSet);
for (Integer integer1 : currentSet) {
weightSet.add(integer + integer1);
}
}
return weightSet.size();
}
}