CF1928D Lonely Mountain Dungeons

Description

Once, the people, elves, dwarves, and other inhabitants of Middle-earth gathered to reclaim the treasures stolen from them by Smaug. In the name of this great goal, they rallied around the powerful elf Timothy and began to plan the overthrow of the ruler of the Lonely Mountain. The army of Middle-earth inhabitants will consist of several squads. It is known that each pair of creatures of the same race, which are in different squads, adds $ b $ units to the total strength of the army. But since it will be difficult for Timothy to lead an army consisting of a large number of squads, the total strength of an army consisting of $ k $ squads is reduced by $ (k - 1) \cdot x $ units. Note that the army always consists of at least one squad. It is known that there are $ n $ races in Middle-earth, and the number of creatures of the $ i $ -th race is equal to $ c_i $ . Help the inhabitants of Middle-earth determine the maximum strength of the army they can assemble.

Input Format

N/A

Output Format

N/A

Explanation/Hint

In the first test case, the inhabitants of Middle-earth can form $ 3 $ squads. Since $ x = 0 $ , the army's strength will not decrease due to the number of squads. The inhabitants can be distributed among the squads as follows: - The single representative of the first species can be sent to the first squad. - The first representative of the second species can be sent to the first squad, the second representative of the second species can be sent to the second squad. Then the total strength of the army will increase by $ b = 1 $ . - The first representative of the third species can be sent to the first squad, the second representative of the third species can be sent to the second squad, the third representative of the third species can be sent to the third squad. Then the total strength of the army will increase by $ 3 \cdot b = 3 $ , as they form three pairs in different squads. Thus, the total strength of the army is $ 4 $ . In the second test case, the inhabitants of Middle-earth can form $ 3 $ squads. Since $ x = 10 $ , the army's strength will decrease by $ 20 $ . The inhabitants can be distributed among the squads as follows: - The first representative of the first species can be sent to the first squad, the second representative of the first species can be sent to the second squad. Then the total strength of the army will increase by $ b = 5 $ . - The first and second representatives of the second species can be sent to the first squad, the third and fourth representatives of the second species can be sent to the second squad, the fifth representative of the third species can be sent to the third squad. Then the total strength of the army will increase by $ 8 \cdot b = 40 $ . - The first representative of the third species can be sent to the first squad, the second representative of the third species can be sent to the second squad, the third representative of the third species can be sent to the third squad. Then the total strength of the army will increase by $ 3 \cdot b = 15 $ , as they form three pairs in different squads. Thus, the total strength of the army is $ 5 + 40 + 15 - 20 = 40 $ .