Ashish has a secret servant named Hsrada.
Hsrada has N lanterns. Each lantern has a brightness B value associated with it. Consider all K-sized subsets of these lanterns, among all those subsets, find the maximum ambience value of the subset.
The ambience value of a subset = ∑∣Bi−Bj∣∀ i,j∈subset,where i<j.
Task
Find the maximum ambience value.
Notes
Example
Assumptions
Approach
Thus, we get the maximum ambience value of 12.
Input Format
Note: This is the input format that you must use to provide custom input (available above the Compile and Test button).
Output Format
For each test case, print a single integer representing the maximum ambience value.
Constraints
1≤T≤10
1≤K≤N≤2∗105
1≤Bi≤109
The number of test cases T = 1,
For the first Test Case,
Assumptions
Approach
Thus, we get the maximum ambience value of 88.