JOSWAP  Just One Swap
You are given an array of size N. How many distinct arrays can you generate by swapping two numbers for exactly once? The two selected numbers can be equal but their positions in the array must be different.
Input
The first line of the input contains a single integer T, denoting the number of test cases. Every test case starts with an integer N. The next line contains N integers, the numbers of the array.
Output
For each tescase output the answer in a single line.
Constraints:
1 <= T <= 5
1 <= Value of a number in the array <= 100000
2 <= N <= 100000
Example
Input:1
5
2 3 2 3 3
Output:
7
You can generate the following arrays:
2 3 2 3 3
2 2 3 3 3
2 3 3 2 3
2 3 3 3 2
3 2 2 3 3
3 3 2 2 3
3 3 2 3 2
hide comments
invinsible:
20190921 15:58:50
Easy question but words are important 'swapping two numbers for exactly once'. AC in 10th GO.


:D:
20190716 00:01:25
"... by swapping two numbers for exactly once?" 

sfialok98:
20170730 19:55:02
For Case :


shahzada:
20170430 17:46:56
what should be the answer for 


akshayjhamb2:
20170426 05:00:53
Bertho Coder can u check my solution?


vengatesh15:
20170424 22:10:38
simple combinations Ac in 1 go.. 

candide:
20170409 12:26:51
Basic combinatorial logic gives the answer. Use long long. 

Vipul Srivastava:
20170408 11:54:16
Last edit: 20170408 18:06:44 

Vipul Srivastava:
20170407 16:22:00
Are the test cases surely correct?

Added by:  Bertho Coder 
Date:  20170407 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 
Resource:  National High School Programming Contest 2017 