Value

아직 제출이 없습니다시간 제한1초메모리 제한256 MB

문제

Pang believes that one cannot make an omelet without breaking eggs.

For a subset AA of 1,2,,n\\{1,2,\ldots,n\\}, we calculate the score of AA as follows:

  1. Initialize the score as 00.
  2. For any iAi\in A, add a_ia\_i to the score.
  3. For any pair of integers (i,j)(i, j) satisfying i2i\ge 2, j2j\ge 2, iAi\in A and jAj\in A, if there exists positive integer k>1k > 1 such that ik=ji^k=j, subtract b_jb\_j from the score.

Find the maximum possible score over the choice of AA.

입력

The first line contains a single integer nn (1n100000)(1\le n\le 100000).

The second line contains nn integers a_1,a_2,,a_na\_1,a\_2,\ldots,a\_n (1a_i1000000000)(1\le a\_i\le 1000000000).

The third line contains nn integers b_1,b_2,,b_nb\_1,b\_2,\ldots,b\_n (1b_i1000000000)(1\le b\_i\le 1000000000).

출력

Print a single integer xx --- the maximum possible score.