import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        // 砝码的重量
        int[] weights = new int[n];
        // 砝码的个数
        int[] counts = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            counts[i] = sc.nextInt();
        }
        TreeSet<Integer> set = new TreeSet<>();
        // 初始化重量0
        set.add(0);
        // 遍历砝码
        for (int i = 0; i < n; i++) {
            // 存所有结果
            ArrayList<Integer> list = new ArrayList<>(set);
            // 遍历个数
            for (int j = 1; j <= counts[i]; j++) {
                for (int k = 0; k < list.size(); k++) {
                    set.add(list.get(k) + weights[i] * j);
                }
            }
        }
        System.out.println(set.size());
    }
}