#P6539. Maximize Finalists Count
Maximize Finalists Count
Maximize Finalists Count
You are given n integers: \(A_1, A_2, \dots, A_n\). You need to choose a positive integer \(x\) such that there are \(m\ (m\ge2)\) integers among the given \(A_i\) which are divisible by \(x\). The number of finalists is defined as \(s = m \times x\). If for a chosen \(x\), the value of \(m\) is 1 then that option is invalid.
Your task is to find the value of \(s\) as large as possible over all valid choices of \(x\), and output \(s\).
Note: There is always at least one valid choice of \(x\) for the input test cases.
inputFormat
The first line contains a single integer n (n \ge 2).
The second line contains n space-separated integers \(A_1, A_2, \dots, A_n\).
outputFormat
Output a single integer representing the maximum possible value of \(s = m \times x\) among all valid choices of \(x\).
sample
5
3 30 34 5 10
20