value
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

believes that one cannot make an omelet without breaking eggs.

For a subset of , we calculate the score of as follows:
  1. Initialize the score as .
  2. For any , add a_i to the score.
  3. For any pair of integers (i, j) satisfying , , and , if there exists positive integer k > 1 such that , subtract b_j from the score.

Find the maximum possible score over the choice of .

输入描述:

The first line contains a single integer  .
The second line contains integers .
The third line contains integers .

输出描述:

Print a single integer  --- the maximum possible score.
示例1

输入

复制
4
1 1 1 2
1 1 1 1

输出

复制
4
示例2

输入

复制
4
1 1 1 1
1 1 1 2

输出

复制
3