import java.util.HashSet;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);
        int n = scanner.nextInt();
        int[] weights = new int[n];
        int[] counts = new int[n];

        for (int i = 0; i < n; i++) {
            weights[i] = scanner.nextInt();
        }
        for (int i = 0; i < n; i++) {
            counts[i] = scanner.nextInt();
        }

        Set<Integer> totalWeights = new HashSet<>();
        totalWeights.add(0); // 初始重量0

        for (int i = 0; i < n; i++) {
            int weight = weights[i];
            int count = counts[i];
            Set<Integer> currentWeights = new HashSet<>(totalWeights);
            for (int w : currentWeights) {
                for (int j = 1; j <= count; j++) {
                    totalWeights.add(w + j * weight);
                }
            }
        }

        System.out.println(totalWeights.size());
    }
}