logo AlgoBeat OnlineJudge
登录 注册

#214055. [EC Final 2019] Value

内存限制:256 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

believes that one cannot make an omelet without breaking eggs.

For a subset of , we calculate the score of as follows:

  • Initialize the score as .
  • For any , add to the score.
  • For any pair of integers satisfying , , and , if there exists positive integer such that , subtract 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

样例输出 1

4

样例输入 2

4
1 1 1 1
1 1 1 2

样例输出 2

3