Non-Trivial Common Divisor

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

문제

You are given a positive integer sequence AA of length NN. You can remove any numbers from the sequence to make the sequence "friendly". A sequence is called friendly if there exists an integer kk (k>1k>1) such that every number in the sequence is a multiple of kk. Since the empty sequence is friendly, it is guaranteed that you can make the initial sequence friendly.

You noticed that there may be multiple ways to make the sequence friendly. So you decide to maximize the sum of all the numbers in the friendly sequence. Please calculate the maximum sum of the all numbers in the friendly sequence which can be obtained from the initial sequence.

입력

The input consists of a single test case formatted as follows: the first line consists of a single integer NN (1N10001 \le N \le 1000). The i+1i+1-st line consists of an integer A_iA\_i (1A_i1091 \le A\_i \le 10^9) for (1iN)(1 \le i \le N).

출력

Print the maximum sum of all the numbers in the friendly sequence which can be obtained from the initial sequence.