## Maximize Function codechef February 2021 long challenge editorial -

## Problem Statement-

You are given a sequence . Find the maximum value of the expression over all triples of pairwise distinct valid indices .

### Input

- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first line of each test case contains a single integer .
- The second line contains space-separated integers .

### Output

For each test case, print a single line containing one integer ― the maximum value of .

### Constraints

- for each valid

### Subtasks

Subtask #1 (30 points):

Subtask #2 (70 points): original constraints

### Example Input

```
3
3
2 7 5
3
3 3 3
5
2 2 2 2 5
```

### Example Output

```
10
0
6
```

### Explanation

Example case 1: The value of the expression is always . For example, let , and , then it is .

Example case 2: Since all values in the sequence are the same, the value of the expression is always .

Example case 3: One optimal solution is , and , which gives .

### Solution-

Solution will be posted anytime soon stay connect .

Must join Telegram channel -https://t.me/competitiveProgrammingDiscussion

## Comments

## Post a Comment