for _ in range(int(input())):
n = int(input())
l = list(map(int, input().split()))
occur = {}
for c in l:
if c not in occur:
occur[c]=1
else:
occur[c]+=1
nums = list(occur.keys())
nums.sort()
if len(nums)==1:
print(n//2)
else:
tot = 0
ans = 0
for i in range(len(nums)):
tot+=occur[nums[i]]
ans = max(ans, tot*(n-tot))
print(ans)
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,n,a[200005];
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>t;
while(t--)
{
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i];
sort(a+1,a+n+1);a[n+1]=0x3f3f3f3f;
int ans=0;
if (a[1]==a[n])
{
cout<<n/2<<endl;
continue;
}
for (int i=1;i<=n;i++)
{
while(a[i]==a[i+1]&&i<=n) i++;
ans=max(ans,(n-i)*i);
}
cout<<ans<<endl;
}
return 0;
}
3. Longest Substring Without Repeating Characters | 1312. Minimum Insertion Steps to Make a String Palindrome |
1092. Shortest Common Supersequence | 1044. Longest Duplicate Substring |
1032. Stream of Characters | 987. Vertical Order Traversal of a Binary Tree |
952. Largest Component Size by Common Factor | 212. Word Search II |
174. Dungeon Game | 127. Word Ladder |
123. Best Time to Buy and Sell Stock III | 85. Maximal Rectangle |
84. Largest Rectangle in Histogram | 60. Permutation Sequence |
42. Trapping Rain Water | 32. Longest Valid Parentheses |
Cutting a material | Bubble Sort |
Number of triangles | AND path in a binary tree |
Factorial equations | Removal of vertices |
Happy segments | Cyclic shifts |
Zoos | Build a graph |
Almost correct bracket sequence | Count of integers |
Differences of the permutations | Doctor's Secret |