Chefu is Chef's little brother, he is 12 years old and he is new to competitive programming.
Chefu is practicing very hard to become a very skilled competitive programmer and win gold medal in IOI.
Now Chefu is participating in a contest and the problem that he is trying to solve states:
Given an array A of N integers, find any i, j such that i <  j 
and Ai + Aj is maximum possible 
unfortunately, there's no much time left before the end of the contest, so Chefu doesn't have time to think of correct solution, so instead, he wrote a solution that selects a random pair (i,  j) (i <  j) and output Ai + Aj. each pair is equiprobable to be selected.
Now Chefu wants your help to calculate the probability that his solution will pass a particular input.

-----Input-----
First line contains an integer T denoting the number of test-cases.
First line of each test-case contains a single integer N
Second line of each test-case contains N space-separated integers A1 A2 ... AN

-----Output-----
For each test-case output a single line containing a single number denoting the probability that Chefu's solution to output a correct answer. your answer will be accepted if the absolute difference between it and correct answer is less than 1e-6

-----Constraints-----
- 1 ≤ T ≤ 100
- 2 ≤ N ≤ 100
- 1 ≤ Ai ≤ 1,000

-----Example-----
Input:
3
4
3 3 3 3
6
1 1 1 2 2 2
4
1 2 2 3

Output:
1.00000000
0.20000000
0.33333333

Difficulty: EASY
Tags: Mathematics

Complete search

Implementation

Probability
Skill types: Complete search

Starter code:

Solutions:
for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	x = max(l)
	a1 = l.count(x)
	if a1 > 1:
		print((a1 - 1) * a1 / 2 / ((a - 1) * a / 2))
	else:
		l.remove(x)
		m = max(l)
		print(l.count(m) / ((a - 1) * a / 2))


for i in range(int(input())):
	l = int(input())
	lst = list(map(int, input().split()))
	lst1 = []
	for j in range(l - 1):
		for k in range(j + 1, l):
			lst1.append(lst[j] + lst[k])
	print(lst1.count(max(lst1)) / len(lst1))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	list1 = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			list1.append(a[i] + a[j])
	c = 0
	c = max(list1)
	d = 0
	d = n * (n - 1) // 2
	c1 = 0
	c1 = list1.count(c)
	print(c1 / d)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s = {}
	for j in range(n):
		for k in range(j + 1, n, 1):
			if (a[j], a[k]) not in s:
				s[a[j], a[k]] = 1
			else:
				s[a[j], a[k]] = s[a[j], a[k]] + 1
	count = sum(s.values())
	max1 = 0
	for j in range(n):
		for k in range(n):
			if a[j] + a[k] > max1:
				max1 = a[j] + a[k]
	count2 = list(s.values())[-1]
	print(count2 / count)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))[:n]
	arr_desc = sorted(arr, reverse=True)
	maxi = sum(arr_desc[:2])
	count = 0
	for i in range(n - 1):
		for j in range(i + 1, n):
			if arr[i] + arr[j] == maxi:
				count += 1
	total = (n - 1) * n / 2
	print(count / total)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	l = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			l.append(arr[i] + arr[j])
	c = l.count(max(l))
	print('%.8f' % (c / len(l)))


for _ in range(int(input())):
	N = int(input())
	L = list(map(int, input().split()))
	L_copy = L.copy()
	N1 = max(L_copy)
	L_copy.remove(N1)
	N2 = max(L_copy)
	req_out = 0
	for i in range(N):
		for j in range(N):
			if i != j and (L[i] == N1 and L[j] == N2 or (L[i] == N2 and L[j] == N1)):
				req_out += 1
	tot_out = N * (N - 1) / 2
	print(req_out / (2 * tot_out))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	big = a.count(a[-1])
	sec = a.count(a[-2])
	if big == 1:
		print(sec / (n * (n - 1) / 2))
	else:
		print(1.0 if big == n else big * (big - 1) / 2 / (n * (n - 1) / 2))


def main():
	t = int(input())
	while t != 0:
		n = int(input())
		arr = list(map(int, input().split()))
		maxVal = -1
		for i in range(0, n):
			for j in range(i + 1, n):
				temp = arr[i] + arr[j]
				if maxVal < temp:
					maxVal = temp
		count = 0
		for i in range(0, n):
			for j in range(i + 1, n):
				temp = arr[i] + arr[j]
				if maxVal == temp:
					count += 1
		val = n * (n - 1) / 2
		print(count / val)
		t = t - 1

def __starting_point():
	main()
__starting_point()


t = int(input())
for _ in range(t):
	n = int(input())
	integers = list(map(int, input().split()))
	size = n * (n - 1) // 2
	ans = [0] * size
	k = 0
	for i in range(n - 1):
		for j in range(i + 1, n):
			ans[k] = integers[i] + integers[j]
			k += 1
	count = ans.count(max(ans))
	print(count / size)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if arr.count(arr[-1]) > 1:
		temp = arr.count(arr[-1])
		print(format(temp * (temp - 1) / (n * (n - 1)), '.8f'))
	else:
		temp = arr.count(arr[-2])
		print(format(temp * 2 / (n * (n - 1)), '.8f'))


try:
	T = int(input())
	for _ in range(T):
		N = int(input())
		A = list(map(int, input().split()))
		c = 0
		d = []
		for i in range(N):
			for j in range(i + 1, N):
				d.append(A[i] + A[j])
		ans = d.count(max(d)) / len(d)
		print('%0.8f' % ans)
except:
	pass


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	v = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			v.append(a[i] + a[j])
	print(v.count(max(v)) / len(v))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	pair = n * (n - 1) / 2
	maxi = 0
	for i in range(n):
		for j in range(i + 1, n):
			if a[i] + a[j] > maxi:
				maxi = a[i] + a[j]
	count = 0
	for i in range(n):
		for j in range(i + 1, n):
			if a[i] + a[j] == maxi:
				count += 1
	print(count / pair)


from itertools import combinations
for tc in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = []
	for i in list(combinations(a, 2)):
		m.append(i[0] + i[1])
	print(m.count(max(m)) / len(m))


def funny(lst):
	newlst = []
	for i in lst:
		newlst.append(sum(i))
	newlst.sort()
	return newlst.count(max(newlst)) / len(newlst)
n = int(input())
for _ in range(n):
	N = int(input())
	arr = list(map(int, input().split()))
	from itertools import combinations
	lst = list(combinations(arr, 2))
	print('%.8f' % funny(lst))


t = int(input())
while t > 0:
	n = int(input())
	tmp = list(map(int, input().split()))
	dic = {}
	for i in tmp:
		try:
			dic[i] += 1
		except:
			dic[i] = 1
	nume = max(dic.keys())
	tmpset = []
	for i in dic.keys():
		if i != nume:
			tmpset.append(i)
	if len(tmpset) != 0 and dic[nume] < 2:
		tmpsed = max(tmpset)
		num = dic[tmpsed] * dic[nume] * 2
	else:
		num = (dic[nume] - 1) * dic[nume]
	ans = num / (n * (n - 1))
	print(ans)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	lsa = list(set(a))
	lsa.sort()
	(maxc, max2c) = (a.count(lsa[-1]), 0)
	if len(lsa) != 1:
		max2c = a.count(lsa[-2])
	if maxc == 1:
		print('{:.8f}'.format(max2c / (n * (n - 1) / 2)))
	else:
		print('{:.8f}'.format(maxc * (maxc - 1) / 2 / (n * (n - 1) / 2)))


from collections import Counter
for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	B = Counter(A)
	if B[A[0]] > 1:
		prob = B[A[0]] * (B[A[0]] - 1) / (N * (N - 1))
	else:
		prob = 2 * B[A[0]] * B[A[1]] / (N * (N - 1))
	print('%10.8f' % prob)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	f = []
	for i in range(n):
		for j in range(i + 1, n):
			f.append(a[i] + a[j])
	maxi = f.count(max(f))
	ans = maxi / len(f)
	print(format(ans, '.6f'))


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	l = []
	for i in range(n):
		for j in range(i + 1, n):
			if i < j:
				l.append(lst[i] + lst[j])
	print(l.count(max(l)) / len(l))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in range(n):
		for j in range(i + 1, n):
			l.append(a[i] + a[j])
	print(l.count(max(l)) / len(l))


def fact(n):
	f = 0
	for i in range(n):
		f = f + i
	return f
t = int(input())
for c in range(t):
	r = int(input())
	l = list(map(int, input().rsplit(' ')))
	l.sort()
	if l.count(l[-1]) >= 2:
		num = l.count(l[-1])
		num = fact(num)
	else:
		nl = []
		for i in l:
			if i not in nl:
				nl.append(i)
		num = l.count(l[-1]) * l.count(nl[-2])
	prob = num / fact(r)
	print(prob)


for _ in range(int(input())):
	K = int(input())
	arr = list(map(int, input().split()))
	P = []
	for i in range(K):
		for j in range(i + 1, K):
			P.append(arr[i] + arr[j])
	print(P.count(max(P)) / len(P))


t = int(input())
while t:
	N = int(input())
	A = list(map(int, input().split()))
	l = []
	for i in range(N):
		for j in range(i + 1, N):
			l.append(A[i] + A[j])
	c = l.count(max(l))
	print(c / len(l))
	t = t - 1


for i in range(int(input())):
	N = int(input())
	l = list(map(int, input().split()))[:N]
	sum = l[N - 1] + l[N - 2]
	count = 0
	max = 0
	for i in range(len(l)):
		for j in range(i + 1, len(l)):
			if l[i] + l[j] > max:
				max = l[i] + l[j]
	for i in range(len(l)):
		for j in range(i + 1, len(l)):
			s = l[i] + l[j]
			if s == max:
				count += 1
	f = N * (N - 1) / 2
	print(format(count / f, '.8f'))


def choose(x):
	return x * (x - 1) // 2
a = int(input())
for i in range(a):
	n = int(input())
	l = list(map(int, input().split()))
	total = choose(n)
	l.sort(reverse=True)
	c0 = l.count(l[0])
	c1 = 0
	if c0 == 1:
		c1 = l.count(l[1])
		print(format(c1 / total, '.8f'))
	else:
		print(format(choose(c0) / total, '.8f'))


t = int(input())
for tc in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for j in range(n):
		for k in range(j + 1, n):
			if j < k:
				b.append(a[j] + a[k])
	print(b.count(max(b)) / len(b))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	max = 0
	t = 0
	for x in range(n):
		for y in range(x + 1, n):
			t += 1
			if l[x] + l[y] > max:
				max = l[x] + l[y]
	count = 0
	for x in range(n):
		for y in range(x + 1, n):
			if l[x] + l[y] == max:
				count += 1
	print(count / t)


test = int(input())
while test:
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	total = n * (n - 1) // 2
	if a[-1] == a[-2]:
		ct = a.count(a[-1])
		print(ct * (ct - 1) // 2 / total)
	else:
		ct = a.count(a[-1]) * a.count(a[-2])
		print(ct / total)
	test -= 1


tc = int(input())
for i in range(tc):
	N = int(input())
	l = list(map(int, input().split()))
	su = []
	for i in range(N - 1):
		for j in range(i + 1, N):
			su.append(l[i] + l[j])
			mx = su.count(max(su))
	print(mx / len(su))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))[:n]
	l = []
	for j in range(len(a)):
		for k in range(j + 1, len(a)):
			l.append(a[j] + a[k])
	print(l.count(max(l)) / (n * (n - 1) / 2))


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	x = sorted(x)
	l = set(x)
	l = list(l)
	if len(l) == 1:
		s = n * (n - 1) // 2
	else:
		a = l[-1]
		b = l[-2]
		if x.count(a) > 1:
			p = x.count(a)
			s = p * (p - 1) // 2
		else:
			p = x.count(a)
			q = x.count(b)
			s = p * q
	c = n * (n - 1) // 2
	print(s / c)


from itertools import combinations
t = int(input())

def pair(arr):
	maxi = 0
	k = 0
	d = 0
	if len(set(arr)) == 1:
		return '{:.8f}'.format(1)
	c = list(combinations(arr, 2))
	for i in c:
		if sum(i) > maxi:
			maxi = sum(i)
		d += 1
	for i in c:
		if sum(i) == maxi:
			k += 1
	p = k / d
	return '{:.8f}'.format(p)
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	r = pair(arr)
	print(r)


def fac(n):
	r = 1
	for i in range(2, n + 1):
		r *= i
	return r

def ncr(n, r):
	a = fac(n)
	b = fac(r) * fac(n - r)
	return a / b
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m1 = max(l)
	if l.count(m1) > 1:
		print(ncr(l.count(m1), 2) / ncr(n, 2))
		continue
	l.remove(m1)
	m2 = max(l)
	print(l.count(m2) / ncr(n, 2))


import numpy as np

def probability(A):
	max_sum = max((A[i] + A[j] for i in range(len(A)) for j in range(i + 1, len(A))))
	max_pairs = [(i, j) for i in range(len(A)) for j in range(i + 1, len(A)) if A[i] + A[j] == max_sum]
	total_pairs = len(A) * (len(A) - 1) // 2
	return len(max_pairs) / total_pairs
for i in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	print('{0:.8f}'.format(probability(A)))


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	B = []
	for i in range(N - 1):
		for j in range(i + 1, N):
			B.append(A[i] + A[j])
	C = max(B)
	D = N * (N - 1) // 2
	count = B.count(C)
	print('%0.8f' % (count / D))


t = int(input())
while t != 0:
	n = int(input())
	l = list(map(int, input().split()))
	m = max(l)
	c = l.count(m)
	if c > 1:
		print((c - 1) * c / 2 / ((n - 1) * n / 2))
	else:
		l.remove(m)
		mx = max(l)
		print(l.count(mx) / ((n - 1) * n / 2))
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	s = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			s.append(l[i] + l[j])
	m = s.count(max(s))
	print('%.8f' % (m / len(s)))


try:
	for _ in range(int(input())):
		n = int(input())
		l = list(map(int, input().split()))
		p = []
		for i in range(n):
			for j in range(i + 1, n):
				p.append(l[i] + l[j])
		m = p.count(max(p)) / len(p)
		print('%.8f' % m)
except:
	pass


t = int(input())
for ni in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	l1 = list()
	for i in range(n):
		for j in range(i):
			s = l[i] + l[j]
			l1.append(l[i] + l[j])
	a = l1.count(max(l1))
	print(a / len(l1))


def main():
	t = int(input())
	while t != 0:
		n = int(input())
		arr = list(map(int, input().split()))
		arr.sort()
		maxEle = arr[n - 1]
		num = n * (n - 1) / 2
		count1 = arr.count(maxEle)
		if count1 == 1:
			count2 = arr.count(arr[n - 2])
			print(count2 / num)
		else:
			val = count1 * (count1 - 1) / 2
			print(val / num)
		t = t - 1

def __starting_point():
	main()
__starting_point()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	li = []
	for i in range(n):
		for j in range(i + 1, n):
			li.append(l[i] + l[j])
	m = max(li)
	p = li.count(m) / len(li)
	print(p)


t = int(input())
while t != 0:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if arr.count(arr[-1]) > 1:
		temp = arr.count(arr[-1])
		print(format(temp * (temp - 1) / (n * (n - 1)), '.6f'))
	else:
		temp = arr.count(arr[-2])
		print(format(temp * 2 / (n * (n - 1)), '.6f'))
	t -= 1


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	arr.sort()
	mxsum = arr[-1] + arr[-2]
	psum = 0
	if arr[-1] != arr[-2]:
		(f, s) = (arr.count(arr[-1]), arr.count(arr[-2]))
		psum = f * s
	else:
		psum = arr.count(arr[-1])
		psum = psum * (psum - 1) // 2
	tt = n * (n - 1) // 2
	print(format(psum / tt, '.8f'))


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	c = 0
	mc = 0
	maxy = li[0]
	for i in range(n - 1):
		for j in range(i + 1, n):
			c += 1
			t = li[j] + li[i]
			if maxy < t:
				maxy = t
				mc = 0
			if t == maxy:
				mc += 1
	print(mc / c)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			s.append(l[i] + l[j])
			mx = s.count(max(s))
	print('{:.8f}'.format(mx / len(s)))


t = int(input())
while t:
	n = int(input())
	l = list(map(int, input().split()))
	max = 0
	c = 0
	for i in range(n):
		for j in range(i + 1, n):
			if l[i] + l[j] > max:
				max = l[i] + l[j]
	for i in range(n):
		for j in range(i + 1, n):
			if l[i] + l[j] == max:
				c += 1
	x = n * (n - 1) / 2
	print(c / x)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sorted(a)
	attemps = list()
	mp = s[-1] + s[-2]
	for c in range(n):
		for i in range(c + 1, n):
			attemps.append(a[c] + a[i])
	resul = float(attemps.count(mp) / len(attemps))
	print(f'{resul:.8f}')


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())), reverse=True)
	i = 1
	while i < n - 1 and a[i] == a[i + 1]:
		i += 1
	if a[0] == a[1]:
		print(i * (i + 1) / (n * (n - 1)))
	else:
		print(2 * i / (n * (n - 1)))


for _ in range(int(input())):
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	if a[-1] == a[-2]:
		c = a[-1]
		count = 0
		for i in range(len(a) - 1, -1, -1):
			if a[i] == c:
				count += 1
			else:
				break
		print(count * (count - 1) / (n * (n - 1)))
	else:
		c = a[-2]
		count = 0
		for i in range(len(a) - 2, -1, -1):
			if a[i] == c:
				count += 1
			else:
				break
		print(count * 2 / (n * (n - 1)))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	maxi = 0
	c = 0
	t = 0
	for i in range(n):
		for j in range(i + 1, n):
			t += 1
			if a[i] + a[j] > maxi:
				maxi = a[i] + a[j]
	for i in range(n):
		for j in range(i + 1, n):
			if a[i] + a[j] == maxi:
				c += 1
	print(c / t)


try:
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = list(map(int, input().split()))
		from itertools import combinations
		ans = []
		for l in combinations(arr, 2):
			ans.append(l)
		maxx = 0
		for l in ans:
			m = sum(l)
			if m > maxx:
				maxx = m
		count = 0
		for l in ans:
			item = sum(l)
			if item < maxx:
				count += 1
		print(1 - count / len(ans))
		continue
except:
	pass


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = a.count(max(a))
	if f == 1:
		a.remove(max(a))
		s = max(a)
		t = a.count(s)
		c = f + t - 1
		num = c
	else:
		c = f
		num = (c ** 2 - c) // 2
	den = (n ** 2 - n) // 2
	print('%.8f' % (num / den))


t = int(input())
for dummy in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = a.copy()
	b.sort()
	best = a.count(b[-1])
	if best >= 2:
		print(best * (best - 1) / (n * (n - 1)))
	else:
		best2 = a.count(b[-2])
		print(best2 * 2 / (n * (n - 1)))


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))[:N]
	l = []
	for j in range(len(A)):
		for k in range(j + 1, len(A)):
			l.append(A[j] + A[k])
	print(l.count(max(l)) / (N * (N - 1) / 2))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	su = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			su.append(l[i] + l[j])
			mx = su.count(max(su))
	print('{:.8f}'.format(mx / len(su)))


T = int(input())
for i in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	L = []
	for j in range(N):
		for k in range(j + 1, N):
			if j < k:
				L.append(A[j] + A[k])
	print(L.count(max(L)) / len(L))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split(' ')))
	l = len(set(a))
	b = n * (n - 1) / 2
	a.sort(reverse=True)
	q = a[0]
	w = a[1]
	if q == w:
		h = a.count(q)
		p = h * (h - 1) / 2
		print(p / b)
	else:
		print(a.count(w) / b)


T = int(input())
for i in range(T):
	l = int(input())
	x = input().split(' ')
	y = []
	for j in range(l):
		y.append(int(x[j]))
	y.sort()
	count = 0
	max = y[-1] + y[-2]
	for k in range(l):
		for m in range(l):
			if k != m and y[k] + y[m] == max:
				count += 1
	print(count / (l * (l - 1)))


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))[:n]
	ans = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			if i < j:
				ans.append(arr[i] + arr[j])
	print(ans.count(max(ans)) / len(ans))
	t -= 1


from collections import Counter
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort(reverse=True)
	B = Counter(A)
	if B[A[0]] > 1:
		p = B[A[0]] * (B[A[0]] - 1) / (n * (n - 1))
	else:
		p = 2 * B[A[0]] * B[A[1]] / (n * (n - 1))
	print(p)


for t in range(int(input())):
	n = int(input())
	a = [int(A) for A in input().split()]
	pairs = []
	m = 0
	for i in range(n):
		for j in range(i):
			pairs.append((a[i], a[j]))
			if a[i] + a[j] > m:
				m = a[i] + a[j]
	count = 0
	for x in pairs:
		if x[0] + x[1] == m:
			count += 1
	print(count / len(pairs))


t = int(input())
for i in range(t):
	x = int(input())
	y = list(map(int, input().split()))
	z = []
	for j in range(0, len(y)):
		for k in range(j + 1, len(y)):
			a = y[j] + y[k]
			z.append(a)
	print(z.count(max(z)) / len(z))