## GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

## [Solution] Army Training CodeChef Solution | Solution Codechef

Chef is a high-ranked army officer and he has been given the job to train the army.

The army consists of $N$ soldiers where each soldier has $3$ parameters:

• Attack points${A}_{i}$ where $\left(0<{A}_{i}<1000\right)$;
• Defense points$\left(1000-{A}_{i}\right)$;
• Soldier typeATTACK or DEFENSE.

For the whole army:

• Attack value of the army is defined as the sum of attack points of all ATTACK type soldiers.
• Defense value of the army is defined as the sum of defense points of all DEFENSE type soldiers.
• Rating of the army is defined as the product of Attack value and Defense value of the army.

Solution Click Below:-  👉
👇👇👇👇👇

Assign the soldier type to each of the soldiers to maximize the rating of the army. Print the maximum rating.

NOTE: The output may exceed the range of a $32$-bit integer.
Remember to use $64$-bit data types, such as long long in C++.

### Input Format

• The first line of input will contain a single integer $T$, denoting the number of test cases.
• Each test case consists of multiple lines of input.
• The first line of each test case contains an integer $N$ — the number of soldiers in the army.
• The next line contains the array $A$ — where ${A}_{i}$ denotes the attack points of the ${i}^{th}$ soldier.

### Output Format

For each test case, output on a new line the maximum possible rating that can be achieved.

### Constraints

• $1\le T\le 100$
• $2\le N\le 1000$
• $0<{A}_{i}<1000$
• Sum of $N$ over all test cases does not exceed $2000$