L. Lost in MST
time limit per test
5 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

One day, Colin got lost in a complete undirected graph $$$G$$$ with $$$n$$$ vertices, and each vertex $$$i$$$ is associated with a magic parameter $$$c_i$$$. For each pair of vertices $$$(i,j)$$$, there exists an undirected edge connecting them with weight $$$w_{i,j} = \gcd(c_i, c_j) + \text{lcm}(c_i, c_j)$$$.

Can you find the graph's minimum spanning tree $$$G$$$ to save Colin?

Recall that $$$\gcd(x, y)$$$ is the greatest common divisor of $$$x$$$ and $$$y$$$, and $$$\text{lcm}(x, y)$$$ is the least common multiple of $$$x$$$ and $$$y$$$.

Input

The first line contains a single integer $$$n~(1\le n\le 10^5)$$$, representing the number of vertices in the graph.

The second line contains $$$n$$$ positive integers $$$c_1,c_2,\cdots,c_n~(1\le c_i\le 10^6)$$$.

Output

Output a single line with a single integer, representing the total weight of the edges in the minimum spanning tree of $$$G$$$.

Example
Input
4
7 8 9 10
Output
163