# Good Indices CodeChef Solution

### We Are Discuss About CODECHEF SOLUTION

Good Indices CodeChef Solution

## Good Indices CodeChef Solution

Chef has an array A of length N.

He calls an index i (1 \leq i \leq N) good if there exists some j \neq i such that A_i = A_j.

Chef can perform the following operation at most once:

• Choose any subsequence of the array A and add any positive integer to all the elements of the chosen subsequence.

Determine the maximum number of good indices Chef can get.

### Input Format

• The first line of input will contain a single integer T, denoting the number of test cases.
• Each test case consists of two lines of input.
• The first line of each test case contains a single integer N denoting the length of the array A.
• The second line contains N space-separated integers denoting the array A.

### Output Format

For each test case, output the maximum number of good indices Chef can get after performing the given operation at most once.

### Constraints

• 1 \leq T \leq 500
• 2 \leq N \leq 1000
• 1 \leq A_i \leq 1000
• The sum of N over all test cases won’t exceed 2000.

### Sample 1:

Input

Output

3
6
1 3 5 2 4 8
4
2 3 4 5
7
1 1 2 2 3 4 4

4
4
7

## SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE