## boring sum

Time Limit: 2 Second(s)    Memory Limit: 32 MB

Total Submission(s): 26   Accepted Submission(s): 9
Problem Description

Number theory is interesting, while this problem is boring.
Here is the problem. Given an integer sequence a, a, …, a[n], let S(i) = {a[j]|1<=j<i, and a[j] is a multiple of a[i]}. If S(i) is not empty, let f(i) be the maximum integer in S(i); otherwise, f(i) = a[i]. Now we define b[¬i] as f(i). Similarly, let T(i) = {a[j]|i<j<=n, and a[j] is a multiple of a[i]}. If T(i) is not empty, let g(i) be the minimum integer in T(i); otherwise, g(i) = a[i]. Now we define c[i] as g(i). The boring sum of this sequence is defined as b * c + b * c + … + b[n] * c[n].
Given an integer sequence, your task is to calculate its boring sum.

Input

The input contains multiple test cases.
Each case consists of two lines. The first line contains an integer n (1<=n<=100000). The second line contains n integers a1, a2, …, an (1<= ai<=100000).
The input is terminated by n = 0.

Output

Output the answer in a line.

Sample Input
```5
1 4 2 3 9
0
```
Sample Output
```134
```
Source

2014市赛