#P17011. [GESP202606 五级] 晚宴
[GESP202606 五级] 晚宴
Problem Description
Xiaoming goes to a banquet. There are dishes at the banquet, and each dish has a tastiness value. The tastiness of the -th dish is .
The banquet rules say that Xiaoming can select exactly two dishes, and the tastiness values of these two dishes must be coprime (i.e., their greatest common divisor is ).
Please help Xiaoming choose two dishes so that the sum of their tastiness values is as large as possible.
Input Format
The input has lines.
The first line contains a positive integer , representing the number of dishes.
The second line contains integers , representing the tastiness values of the dishes. The integers are separated by spaces.
Output Format
Output one integer, representing the maximum possible sum of tastiness values of two coprime dishes.
5
3 5 7 35 105
38
Hint
Sample Explanation 1
The best choice is and .
Note that the greatest common divisor of and any other dish is greater than , so it cannot be part of a valid choice.
Constraints
, .
The testdata guarantees that there are no dishes with the same tastiness value.
The testdata guarantees that there is at least one way to select two dishes.
Translated by ChatGPT 5