cho.sh
Notes
Loading...

Hongjun Programming Contest

Time limit

2s

Memory limit

128 MB

Problem

Hongjun is holding a programming contest. Participants must form teams by school, and Hongjun chooses the team size k. If a school's student count is not divisible by k, that school cannot form teams without leaving students out, so it does not participate. Every team has exactly k members.

There are N schools that want to participate. A school joins the preliminary round only if all of its students can be assigned to teams. Every team consists only of students from the same school.

The contest has a preliminary round and a final round. After the preliminary round, exactly one first-place team from each participating school advances to the final. Therefore, if c schools have student counts divisible by k, the final round has k * c participants.

Because this is the first year of the contest, Hongjun wants as many people as possible in the final round. However, at least two teams must advance to the final. Find the maximum possible number of final-round participants.

Input

The first line contains the number of schools N (2 <= N <= 200,000).

The second line contains the student counts A_i for the schools. Each A_i is between 1 and 2,000,000, inclusive.

Output

Print the maximum possible number of participants in the final round.

Hint

In the first public test, choosing a team size of 2 lets the schools with 2 and 4 students each send one team to the final, for a total of 4 finalists.