Ezzat has an array of $n$ integers (maybe negative). He wants to split it into two non-empty subsequences $a$ and $b$, such that every element from the array belongs to exactly one subsequence, and the value of $f(a) + f(b)$ is the maximum possible value, where $f(x)$ is the average of the subsequence $x$.

A sequence $x$ is a subsequence of a sequence $y$ if $x$ can be obtained from $y$ by deletion of several (possibly, zero or all) elements.

The average of a subsequence is the sum of the numbers of this subsequence divided by the size of the subsequence.

For example, the average of $[1,5,6]$ is $(1+5+6)/3 = 12/3 = 4$, so $f([1,5,6]) = 4$.


-----Input-----

The first line contains a single integer $t$ ($1 \le t \le 10^3$)— the number of test cases. Each test case consists of two lines.

The first line contains a single integer $n$ ($2 \le n \le 10^5$).

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($-10^9 \le a_i \le 10^9$).

It is guaranteed that the sum of $n$ over all test cases does not exceed $3\cdot10^5$.


-----Output-----

For each test case, print a single value — the maximum value that Ezzat can achieve.

Your answer is considered correct if its absolute or relative error does not exceed $10^{-6}$.

Formally, let your answer be $a$, and the jury's answer be $b$. Your answer is accepted if and only if $\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-6}$.


-----Examples-----

Input
4
3
3 1 2
3
-7 -6 -6
3
2 2 2
4
17 3 5 -3
Output
4.500000000
-12.500000000
4.000000000
18.666666667


-----Note-----

In the first test case, the array is $[3, 1, 2]$. These are all the possible ways to split this array:

$a = [3]$, $b = [1,2]$, so the value of $f(a) + f(b) = 3 + 1.5 = 4.5$.

$a = [3,1]$, $b = [2]$, so the value of $f(a) + f(b) = 2 + 2 = 4$.

$a = [3,2]$, $b = [1]$, so the value of $f(a) + f(b) = 2.5 + 1 = 3.5$.

Therefore, the maximum possible value $4.5$.

In the second test case, the array is $[-7, -6, -6]$. These are all the possible ways to split this array:

$a = [-7]$, $b = [-6,-6]$, so the value of $f(a) + f(b) = (-7) + (-6) = -13$.

$a = [-7,-6]$, $b = [-6]$, so the value of $f(a) + f(b) = (-6.5) + (-6) = -12.5$.

Therefore, the maximum possible value $-12.5$.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Mathematics

Complete search


Solutions:
T = int(input())
for case in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a1 = sum(arr[:n - 1]) / (n - 1) + arr[n - 1]
	print(a1)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ma = l[0]
	s = 0
	for i in l:
		s += i
		if i > ma:
			ma = i
	print((s - ma) / (n - 1) + ma)


import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
inf = float('inf')
en = lambda x: list(enumerate(x))
ceil_ = lambda a, b: (a + b - 1) // b
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())

def solve():
	n = ii()
	arr = rr()
	s = sum(arr)
	m = max(arr)
	x = s - m
	print(m + x / (n - 1))
for _ in ' ' * ii():
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	a = arr[-1]
	b = sum(arr) - a
	ans = b / (n - 1) + a
	print(ans)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(max(a) + (sum(a) - max(a)) / (n - 1))


from sys import *
import math
input = stdin.readline
I = int
R = range
listInput = lambda : list(map(int, input().strip().split()))
lineInput = lambda : map(int, input().strip().split())
sJoin = lambda a, sep: '{}'.format(sep).join(a)
arrJoin = lambda a, sep: '{}'.format(sep).join(map(str, a))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, int(math.sqrt(n) + 1), 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def main():
	for _ in R(I(input())):
		(n,) = lineInput()
		arr = sorted(listInput())
		sumRest = sum(arr[:n - 1]) / (n - 1)
		ans = arr[-1] + sumRest
		print(float('{0:.9f}'.format(ans)))
main()


for s in [*open(0)][2::2]:
	l = sorted(map(int, s.split()))
	print(sum(l[:-1]) / len(l[:-1]) + l[-1])


n = int(input())
h = []
for i in range(n):
	j = int(input())
	g = list(map(int, input().split()))
	d = (sum(g) - max(g)) / (j - 1)
	h.append(max(g) + d)
for i in range(len(h)):
	print(str(h[i]))


for testcase in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a, reverse=True)
	sum1 = a[0]
	sum2 = sum(a[1:])
	max_sum = sum1 + sum2 / (n - 1)
	temp_sum = 0
	for i in range(1, n - 1):
		sum1 += a[i]
		sum2 -= a[i]
		temp_sum = sum1 / (i + 1) + sum2 / (n - i)
		if max_sum < 0 and temp_sum < 0 and (abs(max_sum) > abs(temp_sum)):
			break
		if max_sum > temp_sum:
			break
		max_sum = temp_sum
	print(max_sum)


n = int(input())
for i in range(n):
	b = int(input())
	a = list(map(int, input().strip().split()))[:b]
	d = max(a)
	f = sum(a) - d
	e = d + f / (b - 1)
	print(format(e, '.9f'))


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())
for _ in range(ii()):
	n = ii()
	l = li()
	l.sort()
	l.reverse()
	s = [0] * n
	s[0] = l[0]
	for i in range(1, n):
		s[i] += s[i - 1] + l[i]
	ans = -float('inf')
	for i in range(1, n):
		t = s[i - 1] / i + (s[n - 1] - s[i - 1]) / (n - i)
		ans = max(ans, t)
	print(ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = max(a)
	a.remove(k)
	print(k + sum(a) / (n - 1))


from collections import defaultdict as dd, Counter as C
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	r = sum(a)
	print((r - a[-1]) / (n - 1) + a[-1])


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	a = sorted(a)
	f1 = sum(a[:n - 1]) / (n - 1)
	f2 = a[-1]
	print(f1 + f2)


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	if n == 1:
		print(A[0])
	else:
		print(max(A) + (sum(A) - max(A)) / (n - 1))


num = int(input())
for i in range(num):
	n1 = int(input())
	l1 = list(map(int, input().split()))
	p = max(l1)
	l1.remove(p)
	print('%.9f' % (p + sum(l1) / (n1 - 1)))


import sys
t = int(input())
while t > 0:
	n = int(input())
	ar = list(map(int, input().split()))
	s = sum(ar)
	ar.sort()
	s -= ar[n - 1]
	ans = s / (n - 1)
	ans += ar[n - 1]
	print('%.9f' % ans)
	t -= 1


t = int(input())
while t:
	n = int(input())
	arr = [float(tok) for tok in input().split()]
	arr = sorted(arr)
	su = sum(arr)
	su = su - arr[n - 1]
	val1 = su / (n - 1)
	print(val1 + arr[n - 1])
	t -= 1


def end():
	return 0
test_n = 0
intig_len = 0
intig = []
usless = 0
maxi = 0
sumit = 0
test_n = int(input())
for i in range(0, test_n):
	usless = int(input())
	intig = input().split()
	intig = [int(q) for q in intig]
	maxi = max(intig)
	intig.remove(maxi)
	print(sum(intig) / len(intig) + maxi)
	intig = []
end()


for iii in range(int(input())):
	n = int(input())
	q = list(map(int, input().split()))
	x = sum(q)
	maxx = max(q)
	x = (x - maxx) / (n - 1)
	print(x + maxx)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	m = max(arr)
	s = sum(arr)
	print(m + (s - m) / (n - 1))


def sol(A):
	summ = sum(A)
	A = sorted(A)
	summ1 = 0
	summ2 = 0
	ans = -2 ** 31
	for i in range(len(A) - 1):
		summ1 += A[i]
		summ2 = summ - summ1
		ans = max(ans, summ1 / (i + 1) + summ2 / (len(A) - (i + 1)))
	return ans
x = int(input())
for _ in range(x):
	y = int(input())
	A = list(map(int, input().split()))
	print(sol(A))


def merge(l, r):
	result = []
	n = len(l)
	m = len(r)
	i = 0
	j = 0
	while i < n and j < m:
		if l[i] <= r[j]:
			result.append(l[i])
			i += 1
		else:
			result.append(r[j])
			j += 1
	while i < n:
		result.append(l[i])
		i += 1
	while j < m:
		result.append(r[j])
		j += 1
	return result

def mergesort(list):
	n = len(list)
	if n == 1:
		return list
	mid = n // 2
	left_list = mergesort(list[:mid])
	right_list = mergesort(list[mid:])
	result = merge(left_list, right_list)
	return result
t = input()
t = int(t)
arr = []
for x in range(t):
	n = input()
	s = input()
	arr.append([int(i) for i in s.split()])
out = [0] * t
for x in range(t):
	arr[x] = mergesort(arr[x])
	k = len(arr[x])
	out[x] = arr[x][-1] + sum(arr[x], -arr[x][-1]) / float(k - 1)
for i in out:
	print(i)


for i in range(int(input())):
	n = int(input())
	s = [int(k) for k in input().split()]
	l = max(s)
	s.remove(max(s))
	print(l + sum(s) / len(s))


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	print(max(arr) + (sum(arr) - max(arr)) / (n - 1))


t = int(input())
for u in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	pr1 = []
	su = 0
	for i in range(n):
		su += s[i]
		pr1.append(su)
	pr2 = [0 for i in range(n)]
	su = 0
	for i in range(n - 1, -1, -1):
		su += s[i]
		pr2[i] = su
	for i in range(n):
		if i == 0:
			ma = pr1[i] / (i + 1) + pr2[i + 1] / (n - i - 1)
		elif i != n - 1:
			ma = max(ma, pr1[i] / (i + 1) + pr2[i + 1] / (n - i - 1))
	print('{:.6f}'.format(ma))


n = int(input())
for _ in range(n):
	l = int(input())
	mass = tuple(map(int, input().split()))
	maxi_ = max(mass)
	new_mass = mass[:mass.index(maxi_)] + mass[mass.index(maxi_) + 1:]
	print(sum(new_mass) / len(new_mass) + maxi_)


t = int(input())
answers = []
for _ in range(t):
	n = int(input())
	temp_a = list(map(int, input().split()))
	maxim = max(temp_a)
	temp_a.remove(maxim)
	x = maxim + sum(temp_a) / len(temp_a)
	x = str(float('{:.9f}'.format(x)))
	(m, k) = x.split('.')
	if len(k) < 9:
		k += (9 - len(k)) * '0'
	x = m + '.' + k
	answers.append(x)
for i in answers:
	print(i)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))[:n]
	x = sum(a)
	y = max(a)
	print(y + (x - y) / (len(a) - 1))


t = int(input())
for k in range(t):
	n = int(input())
	s = input()
	ls = s.split(' ')
	ls = list(map(int, ls))
	m = max(ls)
	ls.remove(m)
	ans = m + sum(ls) / len(ls)
	print(round(ans, 9))


t = int(input())
for tt in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = sum(arr[:-1]) / (n - 1) + arr[-1]
	print('{:.9f}'.format(ans))


r = int(input())
for i in range(r):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(round(a[n - 1] + (sum(a) - a[n - 1]) / (n - 1), 9))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	x = max(l)
	s = sum(l)
	print(x + (s - x) / (n - 1))


from sys import stdin, stdout
test = int(stdin.readline())
ans = []
for _ in range(test):
	n = int(stdin.readline())
	inp = list(map(int, stdin.readline().split()))
	inp.sort(reverse=True)
	cumu = [inp[0]]
	for i in range(1, len(inp)):
		cumu.append(inp[i] + cumu[-1])
	maxim = -1e+18
	for i in range(len(inp) - 1):
		maxim = max(maxim, cumu[i] / (i + 1) + (cumu[-1] - cumu[i]) / (len(inp) - i - 1))
	ans.append(maxim)
for i in ans:
	stdout.write(str(i) + '\n')


def process(A):
	A = sorted(A)
	answer = -1 * float('inf')
	S = sum(A)
	S1 = A[0]
	n1 = 1
	answer = max(answer, S1 / n1 + (S - S1) / (n - n1))
	for i in range(1, n - 1):
		n1 += 1
		S1 += A[i]
		answer = max(answer, S1 / n1 + (S - S1) / (n - n1))
	return answer
t = int(input())
for i in range(t):
	n = int(input())
	A = [int(x) for x in input().split()]
	print(process(A))


import os
import sys
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 10 ** 9 + 7
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	a = array()
	ans = (sum(a) - max(a)) / (n - 1) + max(a)
	print(ans)


for i in range(int(input())):
	n = input()
	l = list(map(int, input().split()))
	l = sorted(l)
	m = max(l)
	j = len(l) - 1
	a = l[:j]
	b = l[-1]
	avg = sum(a) / len(a) + b
	print(avg)


def solve():
	n = input()
	nums = [int(x) for x in input().split(' ')]
	mx = max(nums)
	print((sum(nums) - mx) / (len(nums) - 1) + mx)
N = int(input())
for _ in range(N):
	solve()


for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	sm = sum(arr)
	pre = [0] * n
	pre[0] = arr[0]
	for i in range(1, n):
		pre[i] = pre[i - 1] + arr[i]
	ans = -100000000000
	for i in range(0, n - 1):
		fa = pre[i] / (i + 1)
		fb = (sm - pre[i]) / (n - i - 1)
		ans = max(ans, fa + fb)
	print(ans)


n = int(input())
for i in range(n):
	length = int(input())
	lst = list(map(int, input().split()[:length]))
	s = sum(lst)
	m = max(lst)
	result = (s - m) / (len(lst) - 1) + m
	print('{0:.9f}'.format(result))


import statistics as st
testcases = int(input())
for i in range(testcases):
	n = int(input())
	x = list(map(int, input().strip().split()))[:n]
	x.sort()
	y = x[0:n - 1]
	maximum = st.mean(y) + x[n - 1]
	print(maximum)


N = int(input())
for i in range(N):
	m = int(input())
	A = list(map(int, input().split()))
	n = len(A)
	x = max(A)
	c = (sum(A) - x) / (len(A) - 1)
	print(x + c)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	maks = max(a)
	ans = maks + (sum(a) - maks) / (n - 1)
	print(ans)


import sys

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_int():
	return int(sys.stdin.readline())

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_string():
	return sys.stdin.readline().strip()

def printn(n):
	sys.stdout.write(str(n) + '\n')

def solve():
	n = get_int()
	a = get_list()
	mx = max(a)
	s = sum(a)
	ans = mx + (s - mx) / (n - 1)
	printn(ans)
t = get_int()
while t:
	t -= 1
	solve()


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = l[-1] + (sum(l) - l[-1]) / (n - 1)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(a) for a in input().split()]
	print(max(l) + (sum(l) - max(l)) / (n - 1))


t = int(input())
while t:
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	l = []
	c = a[1] - a[0]
	m = c
	ind = 0
	for i in range(1, n - 1):
		if a[i + 1] - a[i] > m:
			m = a[i + 1] - a[i]
			ind = i
	if c == m:
		x = sum(a[0:n - 1]) / (n - 1) + a[-1]
		print('{0:.9f}'.format(x))
	else:
		avg1 = sum(a[0:i + 1]) / (i + 1)
		avg2 = sum(a[i + 1:n]) / (n - 1 - i)
		x = avg1 + avg2
		print('{0:.9f}'.format(x))
	t -= 1


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	maximum = max(a)
	a.remove(maximum)
	sumi = sum(a) / len(a)
	sumi = sumi + maximum
	print(sumi)
	t = t - 1


for i in range(int(input())):
	c = int(input())
	x = list(map(int, input().split()))
	y = max(x)
	x.remove(y)
	print(y + sum(x) / len(x))


import sys, os
from math import sqrt
from collections import defaultdict
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	total = sum(A)
	(temp_sum, cnt) = [0] * 2
	ans = -2000000000
	for i in range(n - 1, 0, -1):
		temp_sum += A[i]
		cnt += 1
		total -= A[i]
		ans = max(ans, temp_sum / cnt + total / (n - cnt))
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	k = max(lst)
	lst.remove(k)
	avg = sum(lst) / len(lst)
	total = k + avg
	print('{0:.10f}'.format(total))


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	arr = list(map(int, input().split()))
	m = max(arr)
	s = sum(arr) - m
	c = s / (n - 1) + m
	print(c)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	max_ = max(arr)
	ans = max_ + (sum(arr) - max_) / (n - 1)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	tmp = input().split()
	a = [0] * n
	i = 0
	for st in tmp:
		a[i] = int(st)
		i += 1
	a = sorted(a)
	sm = sum(a)
	s0 = 0
	is_checked = False
	res = 0
	for i in range(0, n - 1):
		s0 += a[i]
		sm -= a[i]
		f = s0 / (i + 1) + sm / (n - i - 1)
		if not is_checked or f > res:
			res = f
			is_checked = True
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	max_value = max(a)
	del a[a.index(max_value)]
	result = max_value + sum(a) / (n - 1)
	print(result)


t = int(input())
result = []
for i in range(t):
	n = int(input())
	numbers = list(map(int, input().strip().split()))[:n]
	mx = max(numbers)
	numbers.pop(numbers.index(mx))
	ans = mx + sum(numbers) / (n - 1)
	result.append(ans)
for i in result:
	print(i)


import os
import sys
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	_sum = sum(a)
	mx = max(a)
	ans = (_sum - mx) / (n - 1) + mx
	print(ans)


import sys
try:
	for t in range(int(sys.stdin.readline())):
		n = int(sys.stdin.readline())
		a = list(map(int, sys.stdin.readline().split()))
		a.sort()
		a.reverse()
		su1 = sum(a)
		su = a[0]
		su1 = su1 - su
		c = 0
		d = su
		l = n - 1
		d = d + su1 / l
		print('{0:.9f}'.format(d))
except EOFError as e:
	pass


for t in range(int(input())):
	y = int(input())
	l = list(map(int, input().split()))
	a = max(l)
	l.remove(a)
	b = sum(l) / len(l)
	s = a + b
	print('%.9f' % s)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	left = sum(a)
	ans = -10 ** 19
	right = 0
	k = 1
	for i in range(n - 1):
		right += a[i]
		left -= a[i]
		ans = max(right / k + left / (n - k), ans)
		k += 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = 0
	xl = 0
	aa = sum(a)
	aal = len(a)
	ans = -10 ** 18
	for i in a:
		h = a.pop()
		x += h
		aa -= h
		aal -= 1
		xl += 1
		if len(a) != 0:
			ans = max(ans, aa / aal + x / xl)
	print(ans)


for i in range(int(input())):
	n = int(input())
	max = -10 ** 9
	t = 0
	sum = 0
	t = [int(x) for x in input().split()]
	for j in range(n):
		sum += t[j]
		if t[j] > max:
			max = t[j]
	sum -= max
	print(sum / (n - 1) + max)


t = int(input())
for i in range(t):
	n = int(input())
	data = list(map(int, input().split()))
	Max = data.pop(data.index(max(data)))
	ans = Max + sum(data) / (n - 1)
	print(ans)


t = int(input())
for i in range(0, t):
	n = int(input())
	L = list(map(int, input().split()))
	s = 0
	for i in range(0, n):
		s += L[i]
	avg = max(L) + (s - max(L)) / (n - 1)
	print(avg)


test = int(input())
m = []
for i in range(test):
	n = int(input())
	l = list(map(int, input().split()))
	t = max(l)
	l.remove(t)
	s = sum(l) / len(l)
	d = '%.9f' % (t + s)
	m.append(d)
for num in m:
	print(num)


import bisect
import copy

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s

def invr():
	return map(int, input().split())
n = inp()
for _ in range(n):
	x = inp()
	l = inlt()
	s = sum(l)
	m = max(l)
	s -= m
	res = s / (x - 1) + m
	print(round(res, 8))


t = int(input())
while t:
	t -= 1
	N = int(input())
	arr1 = list(map(int, input().split()))
	k1 = max(arr1)
	ans = k1 + (sum(arr1) - k1) / (len(arr1) - 1)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	s = sum(a)
	print(a[-1] + (s - a[-1]) / (n - 1))


def solve():
	n = int(input())
	li = list(map(int, input().split()))
	x = sum(li)
	y = max(li)
	x -= y
	print(y + x / (n - 1))
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	s = sum(arr)
	sumarr = []
	a = 0
	for i in arr:
		a += i
		sumarr.append(a)
	ans = -10 ** 12
	for i in range(n - 1):
		ans = max(ans, sumarr[i] / (i + 1) + (s - sumarr[i]) / (n - i - 1))
	print(ans)


N = int(input())
for _ in range(N):
	n = int(input())
	lst = sorted(list(map(int, input().split())))
	pref_sum = [0]
	for i in range(n):
		pref_sum.append(pref_sum[-1] + lst[i])
	sm = sum(lst)
	mx = -10 ** 18
	for i in range(1, n):
		sm1 = pref_sum[i]
		sm2 = sm - sm1
		val1 = sm1 / i
		val2 = sm2 / (n - i)
		mx = max(mx, val1 + val2)
	print(mx)


for _ in range(int(input())):
	n = int(input())
	arr = (*map(int, input().split()),)
	M = max(arr)
	S = sum(arr)
	print((S - M) / (n - 1) + M)


n = int(input())
for _ in range(n):
	x = int(input())
	ar = list(map(int, input().split()))
	m = max(ar)
	l = len(ar) - 1
	s = sum(ar) - m
	print(round(m + s / l, 9))


import sys
input = sys.stdin.readline
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = sum(a)
	m = max(a)
	print(m + (s - m) / (n - 1))


ret = []
test_case = int(input())
for test_idx in range(test_case):
	n = int(input())
	lst = input().split()
	lst = list(map(lambda x: int(x), lst))
	max_x = -1000000000.0 * 100000.0 * 2
	lst.sort()
	for i in range(n - 1, 0, -1):
		ans = sum(lst[:i]) / i + sum(lst[i:]) / (n - i)
		if max_x < ans:
			max_x = ans
		if ans < max_x:
			break
	ret.append(max_x)
for x in ret:
	print(x)


try:
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		a.sort()
		for i in range(1, n):
			a[i] = a[i] + a[i - 1]
		for i in range(n - 1):
			f = a[i] / (i + 1) + (a[n - 1] - a[i]) / (n - 1 - i)
			if i == 0:
				maxVal = f
			if f > maxVal:
				maxVal = f
		print('%0.9f' % maxVal)
except:
	pass


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split(' ')))
	b = max(a)
	ans = (sum(a) - b) / (n - 1)
	print('{0:.9f}'.format(ans + b))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mx = max(a)
	sm = sum(a)
	sm = sm - mx
	sm = sm / (n - 1)
	sm = mx + sm
	print('{0:.9f}'.format(sm))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = (sum(a) - a[n - 1]) / (len(a) - 1) + a[n - 1] / 1
	print(x)


q = int(input())
for i in range(q):
	n = int(input())
	a = [int(i) for i in input().split()]
	s = 0
	for i in a:
		s += i
	print('%.8f' % (max(a) + (s - max(a)) / (n - 1)))


import os, sys, math
from io import BytesIO, IOBase
ip = lambda : input()
it = lambda : int(input())
ma = lambda : map(int, input().split(' '))
li = lambda : list(map(int, input().split(' ')))
mod = 10 ** 9 + 7

def main():
	for _ in range(int(input())):
		n = it()
		a = li()
		s = sum(a)
		m = max(a)
		ans = m + (s - m) / (n - 1)
		print('%0.12f' % ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(max(a) + (sum(a) - max(a)) / (len(a) - 1))


i = int(input())
for x in range(i):
	a1 = int(input())
	a = [int(c) for c in input().split()]
	maxx = -10000000000000
	maxxindex = -1
	k = 0
	for x in a:
		if maxx < x:
			maxx = x
			maxxindex = k
		k = k + 1
	a.pop(maxxindex)
	print(maxx + sum(a) / a.__len__())


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	biggest = max(l)
	l.pop(l.index(max(l)))
	print(biggest + sum(l) / len(l))


for s in [*open(0)][2::2]:
	s = list(map(int, s.split()))
	print(f'{s.pop(s.index(max(s))) + sum(s) / len(s):.8f}')


def solve():
	n = int(input())
	l = list(map(int, input().split()))
	m = max(l)
	s = sum(l) - m
	s /= n - 1
	print(round(m + s, 9))
for _ in range(int(input())):
	solve()


import statistics
tc = int(input())
n = []
arr = []
answer = []
for j in range(tc):
	n.append(int(input()))
	arr.append([int(i) for i in input().split()])
for j in range(tc):
	current = arr.pop(0)
	current.sort()
	for i in range(len(current) - 1, -1, -1):
		if current[i] == current[i - 1]:
			answer.append(statistics.mean(current[:i]) + statistics.mean(current[i:]))
			break
		else:
			answer.append(statistics.mean(current[:-1]) + current[-1])
			break
for i in answer:
	print(i)


import sys
tc = int(sys.stdin.readline())
for _ in range(tc):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	temp = 0
	val = max(arr)
	cnt = 0
	size = 0
	for i in arr:
		if i == val:
			if not cnt:
				cnt += 1
			else:
				temp += i
				size += 1
		else:
			temp += i
			size += 1
	print(temp / size + val)


n = int(input())
while n:
	n -= 1
	n1 = int(input())
	arr = list(map(int, input().split()))
	k = max(arr)
	ans = k + (sum(arr) - k) / (len(arr) - 1)
	print(ans)


t = int(input())
for case in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	m = max(arr)
	print(f'{m + (sum(arr) - m) / (n - 1):.9f}')


for _ in range(int(input())):
	n = int(input())
	values = list(map(int, input().split()))
	values.sort()
	total_sum = sum(values)
	ans = float('-inf')
	partial_sum = values[0]
	for x in range(1, len(values)):
		a = partial_sum / x
		b = (total_sum - partial_sum) / (n - x)
		ans = max(ans, a + b)
		partial_sum += values[x]
	print(ans)


for _ in range(int(input())):
	n = int(input())
	Arr = list(map(int, input().split()))
	maximum = max(Arr)
	Arr.remove(maximum)
	ans = maximum + sum(Arr) / (n - 1)
	print('%.9f' % ans)


import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(stdin, stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(iinp()):
	n = iinp()
	arr = lmp()
	sm = sum(arr)
	mx = max(arr)
	print((sm - mx) / (n - 1) + mx)


from sys import stdin as sin

def aint():
	return int(input())

def amap():
	return map(int, sin.readline().split())

def alist():
	return list(map(int, sin.readline().split()))

def astr():
	return input()
for _ in range(aint()):
	n = aint()
	l = alist()
	l.sort()
	ans = sum(l[:-1]) / (n - 1) + l[-1]
	print(ans)


t = int(input())
list = []
wyniki = []
maxi = 0
suma = 0
a = []
b = []
n = 0
for i in range(t):
	b = []
	n = int(input())
	a = input().split()
	for j in range(n):
		b.append(int(a[j]))
	maxi = max(b)
	suma = sum(b) - maxi
	list.append(suma / (n - 1) + maxi)
for i in range(t):
	print(list[i])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	top = max(a)
	ave = (sum(a) - top) / (n - 1)
	print(ave + top)


for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	print(max(nums) + (sum(nums) - max(nums)) / (n - 1))


import sys
_DEBUG = False
if _DEBUG:
	fd = open('input.txt', 'r')
	sys.stdin = fd
for t in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	m = max(arr)
	mi = arr.index(m)
	arr.pop(mi)
	fa = sum(arr) / len(arr)
	print(fa + m)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = max(a)
	print(x + (sum(a) - x) / (n - 1))


import math, sys

def yes():
	print('YES')

def no():
	print('NO')
tt = int(input())
for _ in range(tt):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	S = sum(a)
	print((sum(a) - max(a)) / (n - 1) + max(a))


from math import inf

def sol():
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	pref = n * [0]
	suf = n * [0]
	pref[0] = arr[0]
	suf[-1] = arr[-1]
	for i in range(1, n):
		pref[i] = pref[i - 1] + arr[i]
	for i in range(n - 2, -1, -1):
		suf[i] = suf[i + 1] + arr[i]
	for i in range(1, n):
		pref[i] = pref[i] / (i + 1)
	for i in range(n - 2, -1, -1):
		suf[i] = suf[i] / (n - i)
	ans = -inf
	for i in range(1, n):
		ans = max(ans, suf[i] + pref[i - 1])
	print(round(ans, 10))

def main():
	for i in range(int(input())):
		sol()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = max(a)
	a.remove(max(a))
	ans += sum(a) / (n - 1)
	print('{0:.9f}'.format(ans))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	temp = (sum(a) - max(a)) / (n - 1)
	print('%.9f' % (max(a) + temp))


def prob():
	n = int(input())
	l = [int(x) for x in input().split()]
	l.sort()
	k = l[-1]
	p = sum(l[:n - 1])
	p = p / (n - 1)
	print(k + p)
t = 1
t = int(input())
for _ in range(0, t):
	prob()


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = a[-1]
	a.pop()
	print('{:.9f}'.format(sum(a) / len(a) + c))
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	a1 = max(arr)
	arr.remove(a1)
	a2 = sum(arr) / (n - 1)
	print(float(a1 + a2))


(T,) = map(int, input().split())
for _ in range(T):
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	print(max(X) + (sum(X) - max(X)) / (N - 1))


import time

def main():
	t = i_input()
	for tt in range(t):
		n = i_input()
		a = li_input()
		mx = max(a)
		print(mx + (sum(a) - mx) / (n - 1))

def i_input():
	return int(input())

def l_input():
	return input().split()

def li_input():
	return list(map(int, l_input()))

def il_input():
	return list(map(int, l_input()))
TT = time.time()
main()


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	s = sum(l)
	k = 0
	m = float('-inf')
	for i in range(n - 1):
		k += l[i]
		m = max(m, k / (i + 1) + (s - k) / (n - i - 1))
	print(m)


k = int(input())
for i in range(k):
	n = int(input())
	mass = list(map(int, input().split()))
	a = [max(mass)]
	mass1 = mass
	mass1.remove(max(mass))
	res = sum(a) + sum(mass1) / len(mass1)
	print(res)


t = int(input())
res = []
for el in range(t):
	n = int(input())
	s = [int(i) for i in input().split(' ')]
	mx = max(s)
	s.remove(mx)
	res.append(mx + sum(s) / len(s))
for i in res:
	print(i)


from math import *
n = int(input())
while n >= 1:
	n -= 1
	s = 0
	kol = 0
	mx = -1000000000000000000000000
	n1 = int(input())
	d = list(map(int, input().split()))
	z = sum(d)
	mx = max(d)
	print(round(mx + (z - mx) / (n1 - 1), 6))


def dat(l):
	s = max(l)
	l.remove(s)
	return sum(l) / len(l) + s
t = int(input())
for x in range(t):
	n = int(input())
	q = list(map(int, input().split()))
	print(dat(q))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s = []
	now_s = 0
	for i in range(n):
		now_s += a[i]
		s.append(now_s)
	ans = -9999999999999999999
	for i in range(n - 1):
		ans = max(ans, s[i] / (i + 1) + (s[n - 1] - s[i]) / (n - i - 1))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	res = a.pop(a.index(max(a)))
	res += sum(a) / (n - 1)
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split(' ')
	s = [int(num) for num in s]
	s.sort()
	sum_arr = [s[0]]
	for j in range(1, n):
		sum_arr.append(sum_arr[j - 1] + s[j])
	max_num = sum_arr[0] + (sum_arr[n - 1] - sum_arr[0]) / (n - 1)
	for j in range(2, n):
		temp = sum_arr[j - 1] / j + (sum_arr[n - 1] - sum_arr[j - 1]) / (n - j)
		if max_num < temp:
			max_num = temp
	print(max_num)


def int_input():
	a = int(input())
	return a

def int_list_input():
	a = list(map(int, input().split()))
	return a

def solve():
	n = int_input()
	arr = int_list_input()
	maxi = max(arr)
	arr.remove(maxi)
	b = sum(arr) / (n - 1)
	a = maxi + b
	print(a)
for _ in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	res = sum(li[:n - 1])
	res = res / (n - 1) + li[n - 1]
	print(res)


def cast(cre, typ):
	return type(typ)(map(cre, typ))

def inp_lis(cre):
	if cre == str:
		return input().split()
	elif cre == bool:
		return cast(bool, cast(int, input().split()))
	else:
		return cast(cre, input().split())

def repl(str_, idx=-1, char=''):
	leng = len(str_)
	return str_[:idx] + char + str_[(leng + idx) % leng + 1:]

def solution():
	for t in range(int(input())):
		n = int(input())
		seq = inp_lis(int)
		ans = 0
		maxv = max(seq)
		tot = sum(seq)
		ans = (tot - maxv) / (n - 1) + maxv
		print(ans)
	return
solution()


t = int(input())
for tc in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	y = max(x)
	ans = 0
	ans += y
	ans += (sum(x) - y) / (n - 1)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	a = min(arr)
	b = max(arr)
	c = sum(arr)
	print(max(a + (c - a) / (n - 1), b + (c - b) / (n - 1)))


for i in range(int(input())):
	n = int(input())
	a = sorted(list(map(float, input().split())))
	b = sum(a) - max(a)
	c = b / (n - 1)
	d = max(a)
	print(c + d)


for i in range(int(input())):
	j = int(input())
	k = [int(i) for i in input().split()]
	print((sum(k) - max(k)) / (j - 1) + max(k))


import sys
for t in range(int(input())):
	n = int(input())
	arr = [int(ele) for ele in input().split()]
	arr.sort()
	summ1 = arr[0]
	summ2 = sum(arr[1:])
	maxx = summ1 + summ2 / (n - 1)
	for i in range(1, n - 1):
		summ1 += arr[i]
		summ2 -= arr[i]
		sumOfAvg = summ1 / (i + 1) + summ2 / (n - i - 1)
		if sumOfAvg > maxx:
			maxx = sumOfAvg
	print(maxx)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c = max(arr)
	ans = (sum(arr) - c) / (n - 1) + c
	print(round(ans, 9))


def f(a):
	return sum(a) / len(a)
for _ in range(int(input())):
	n = int(input())
	numbers = list(map(int, input().split()))
	x = max(numbers)
	numbers.remove(x)
	print(x + f(numbers))


n = int(input())
for i in range(n):
	x = int(input())
	y = list(map(int, input().split()))
	m = max(y)
	y.remove(m)
	a = sum(y) / len(y)
	print(m + a)


import sys
r = int(input())
for round in range(r):
	n = int(input())
	myList = list(map(int, input().split()))
	maxi = -sys.maxsize
	for i in range(0, len(myList)):
		maxi = max(maxi, myList[i])
	val1 = maxi
	myList.remove(maxi)
	val2 = sum(myList) / len(myList)
	print(val1 + val2)


t = int(input())
while t:
	l = 0
	g = None
	k = int(input())
	p = list(map(int, input().split()))
	l = max(p)
	g = (sum(p) - l) / (len(p) - 1)
	g = g + l
	print(g)
	t = t - 1


t = int(input())
for i in range(t):
	n = int(input())
	m = list(map(int, input().split()))
	mMax = -10000000000
	sum = 0
	for j in range(n):
		if m[j] >= mMax:
			mMax = m[j]
		sum += m[j]
	sum -= mMax
	sum /= n - 1
	print(sum + mMax)


for _ in range(int(input())):
	num = int(input())
	arr = list(map(int, input().split()))
	print(max(arr) + (sum(arr) - max(arr)) / (num - 1))


t = int(input())
results = []
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	dem = 0
	for i in range(0, n - 1):
		dem += a[i]
	result = a[n - 1] + dem / (n - 1)
	results.append(result)
for i in results:
	print(i)


for _ in range(int(input())):
	n = int(input())
	k = input()
	k = k.split()
	k = list(map(int, k))
	j = max(k)
	k.remove(j)
	v = sum(k) / len(k)
	v = round(v, 6)
	print(v + j)


t = int(input())
for i in range(0, t):
	n = int(input())
	lst = list(map(int, input().split()))
	a = sum(lst)
	m = max(lst)
	b = (a - m) / (n - 1)
	print(b + m)


t = int(input())
x = sorted
y = len
z = sum
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = x(a, reverse=True)
	c = b[0]
	d = b[1:]
	print(c + z(d) / y(d))


t = int(input())

def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	s = sum(arr)
	run = 0
	ans = -9999999999999999999999
	for i in range(len(arr) - 1):
		run += arr[i]
		ans = max(ans, run / (i + 1) + (s - run) / (n - i - 1))
	print(ans)
for i in range(t):
	solve()


from heapq import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	a.sort()
	x = -float('inf')
	s1 = 0
	s2 = sum(a)
	for i in range(n):
		if i == n - 1:
			continue
		s1 += a[i]
		y = s1 / (i + 1)
		s2 -= a[i]
		y1 = s2 / (n - i - 1)
		x = max(x, y1 + y)
	print(x)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	g = a[0]
	sum = 0
	for j in range(n):
		g = max(a[j], g)
		sum = sum + a[j]
	ans = g + (sum - g) / (n - 1)
	print(round(ans, 9))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = 0
	som = 0
	for j in range(n):
		if j > 0:
			m += 1
			break
	if m == 0:
		l1 = min(l)
		l.remove(l1)
		for j in range(len(l)):
			som += l[j]
		ans = som / len(l)
		print(ans + l1)
	else:
		l1 = max(l)
		l.remove(l1)
		for j in range(len(l)):
			som += l[j]
		ans = som / len(l)
		print(ans + l1)


def splitting_max(x):
	a = max(x)
	b = (sum(x) - a) / (len(x) - 1)
	return a + b

def main():
	t = int(input())
	for case in range(t):
		n = int(input())
		eins = input().split()
		eins = list(map(int, eins))
		print(splitting_max(eins))
main()


def solve(n, a):
	s = sum(a[:-1])
	return a[-1] + s / (n - 1)
t = int(input())
for i in range(t):
	n = int(input())
	a = sorted(map(int, input().split()))
	print(solve(n, a))


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections, re, itertools, statistics, math
from collections import *
from itertools import *
from statistics import *
from math import *
from re import *
mod = int(1000000000.0 + 7)
imin = -2147483648
imax = 2147483647
true = True
false = False
none = None
inp = lambda : input()
I = lambda : int(inp())
M = lambda : map(int, inp().split())
L = lambda : list(M())
Yes = lambda : print('Yes')
No = lambda : print('No')
YES = lambda : print('YES')
NO = lambda : print('NO')
chartonum = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '0': 0}

def IO(controll):
	if controll == false:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		pass

def true_yes(statement):
	return YES() if statement else NO()

def state(statement, one, two):
	print(one if statement else two)

def swap(a, b):
	(a, b) = (b, a)

def debug(something):
	print(*something)

def prec(a):
	return '{0:.9f}'.format(a)

def binary_search(arr, low, high, x):
	while low <= high:
		mid = low + (high - low) // 2
		if arr[mid] == x:
			return [mid, true]
		elif arr[mid] > x:
			high = mid - 1
		else:
			low = mid - 1
	return [-1, false]

def kabraji_ka_totka():
	IO(1)
	for i in range(I()):
		n = I()
		arr = L()
		arr.sort()
		sum = 0
		for i in range(n - 1):
			sum += arr[i]
		res = arr[n - 1] + float(float(sum) / (n - 1))
		print(prec(res))
kabraji_ka_totka()


def solve(n, a):
	b = max(a)
	a.pop(a.index(max(a)))
	return b + sum(a) / len(a)
test_cases = int(input())
for _ in range(test_cases):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	max1 = max(l)
	sum1 = sum(l) - max1
	res = max1 * 1.0 + sum1 / (n - 1)
	print('{:.9f}'.format(res))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def intArr():
	return map(int, input().split())

def In():
	return int(input())

def func():
	n = In()
	arr = list(intArr())
	m = max(arr)
	return m + (sum(arr) - m) / (n - 1)

def main():
	for _ in range(In()):
		print(func())
	return
main()


nums = list()
N = int(input())
maior = media = 0
for a in range(N):
	media = 0
	nums = list()
	quant = int(input())
	nums = list(map(int, input().split()))
	maior = nums[0]
	for n in nums:
		if n > maior:
			maior = n
	nums.remove(maior)
	for c in nums:
		media += c
	media /= quant - 1
	print(media + maior)


for j in range(int(input())):
	t = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=True)
	s = l[0] + (sum(l) - l[0]) / (len(l) - 1)
	print(s)


def main():
	from sys import stdin, setrecursionlimit
	input = stdin.buffer.readline
	for _ in range(int(input())):
		n = int(input())
		a = sorted(map(int, input().split()))
		s = sum(a)
		c = s
		ans = -10 ** 20
		for i in range(n - 1):
			c -= a[i]
			ans = max(ans, (s - c) / (i + 1) + c / (n - i - 1))
		print(ans)
main()


t = int(input())
for i in range(t):
	n = int(input())
	na = list(map(int, input().split()))
	first = max(na)
	na.remove(first)
	remain_sumav = sum(na) / (n - 1)
	ans = first + remain_sumav
	print(ans)


def max_avg_sum(arr_size, arr):
	max_element = max(arr)
	arr.remove(max_element)
	return max_element + sum(arr) / (arr_size - 1)
test_cases = int(input())
for _ in range(test_cases):
	arr_size = int(input())
	arr = list(map(int, input().split()))
	print('{0:.9f}'.format(max_avg_sum(arr_size, arr)))


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	sumi = 0
	suma = sum(a)
	ans = -10 ** 18
	for i in range(n - 1):
		sumi += a[i]
		if sumi / (i + 1) + (suma - sumi) / (n - i - 1) > ans:
			ans = sumi / (i + 1) + (suma - sumi) / (n - i - 1)
	print(ans)
t = int(input())
for _ in range(t):
	solve()


import sys
import math
from collections import deque
from bisect import bisect_left, bisect_right
I = sys.stdin.readline
II = lambda : int(I())
IN = lambda x: map(int, x.split())
FN = lambda x: map(float, x.split())
L = lambda x: list(IN(x))
M = 1000000007
P = print
T = True
F = False
for _ in range(II()):
	n = II()
	a = L(I())
	m = max(a)
	s = sum(a) - m
	res = m + s / (n - 1)
	print(res)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	val = max(arr)
	total = (sum(arr) - val) / (n - 1)
	total += val
	print(format(total, '.9f'))


t = int(input())
for i in range(t):
	n = int(input())
	lst = [j for j in input().split(' ')]
	lst = [int(j) for j in lst]
	xr = 0
	cnt = 0
	for j in range(len(lst)):
		xr = xr + lst[j]
		cnt += 1
	mx = max(lst)
	ans = xr - mx
	ans2 = ans / (cnt - 1) + mx
	print(ans2)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	i = 1
	j = n - 1
	s1 = 0
	s2 = sum(l)
	ans = float('-inf')
	for k in l[:n - 1]:
		s1 += k
		s2 -= k
		ans = max(ans, s1 / i + s2 / j)
		i += 1
		j -= 1
	print(ans)


test_cases = int(input())
for test in range(test_cases):
	n = int(input())
	seq = list(map(int, input().split()))
	fa = seq.pop(seq.index(max(seq)))
	fb = sum(seq) / len(seq)
	print(fa + fb)


def sum(A):
	sum = 0
	for i in range(len(A)):
		sum += A[i]
	return sum

def f(A):
	return ((len(A) - 2) * max(A) + sum(A)) / (len(A) - 1)

def Ezzat():
	cases = int(input())
	for case in range(cases):
		n = int(input())
		A = list(map(int, input().split()))
		print(f(A))
Ezzat()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort(reverse=True)
	sa = arr[0]
	cb = 1
	ca = 1
	sb = arr[1]
	arr.remove(sa)
	arr.remove(sb)
	for i in arr:
		if (sa + i) / (ca + 1) + sb / cb > (sb + i) / (cb + 1) + sa / ca:
			sa += i
			ca += 1
		else:
			sb += i
			cb += 1
	if sb == 0:
		print(sa / ca)
		continue
	print(sa / ca + sb / cb)


import sys
from sys import stdin, stdout
for i in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	m = max(a)
	a.remove(m)
	s = sum(a)
	ans = s / (n - 1) + m
	res = '{:.9f}'.format(ans)
	sys.stdout.write(str(res) + '\n')


t = int(input())

def solve():
	n = int(input())
	v = list(map(int, input().split(' ')))
	mx = max(v)
	sm = 0
	for el in v:
		sm += el
	res = 1.0 * (sm - mx) / (n - 1) + mx
	print(res)
for _ in range(t):
	solve()


t = int(input())
from functools import reduce

def sp():
	n = int(input())
	l = []
	l = list(map(int, input().split()))
	n = max(l)
	l.remove(n)
	k = sum(l) / len(l)
	y = n + k
	print(y)
for i in range(t):
	sp()


t = int(input())
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	f_a = float(a[-1])
	f_b = sum(a[0:-1]) / (len(a) - 1)
	print(f_a + f_b)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mx = arr[0]
	sum = 0
	for i in range(n):
		if arr[i] > mx:
			mx = arr[i]
		sum += arr[i]
	print(1.0 * ((sum - mx) / (n - 1) + mx))


import sys
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, arr):
	arr.sort()
	tot = arr[-1]
	tot += sum(arr[:-1]) / len(arr[:-1])
	print(f'{tot:.9f}')
for _ in range(int(input())):
	n = int(input())
	arr = int_arr()
	solve(n, arr)


try:
	t = int(input())
	for i in range(t):
		N = int(input())
		l = list(map(int, input().split()))
		a = max(l)
		l.remove(a)
		b = l
		c = a + sum(b) / len(b)
		print(c)
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	s = [a[0]]
	for i in range(1, n):
		s.append(s[-1] + a[i])
	ans = -10 ** 10
	for i in range(n - 1):
		ans = max(ans, s[i] / (i + 1) + (s[-1] - s[i]) / (n - i - 1))
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	f = max(a)
	a.remove(f)
	print(sum(a) / len(a) + f)


import random
from statistics import mean

def main():
	N = int(input())
	l = [int(i) for i in input().split()]
	g = l
	copyg = g.copy()
	copyg.remove(max(g))
	smax = max(g) + mean(copyg)
	return smax
num_of_cases = [int(i) for i in input().split()][0]
for p in range(num_of_cases):
	output = main()
	print('{1}'.format(p + 1, output))


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	m = max(x)
	s = sum(x) - m
	print(m + s / (n - 1))


import sys

def debug(*a):
	print(a, file=sys.stderr)

def read(typ=str):
	return typ(input())

def read_arr(typ=int):
	return list(map(typ, input().split()))
tt = read(int)
for t in range(tt):
	n = read(int)
	arr = read_arr(int)
	tot = sum(arr)
	mx = max(arr)
	tot -= mx
	ans = tot / (n - 1)
	ans += mx
	print(ans)


t = int(input())
while t:
	n = int(input())
	arr = [int(x) for x in input().split()]
	mx = max(arr)
	total = sum(arr)
	total = total - mx
	total = total / (n - 1)
	a = total + mx
	print('%.9f' % a)
	t = t - 1


n = int(input())
for i in range(n):
	m = int(input())
	a = list(map(int, input().split(' ')))
	me = max(a)
	s = sum(a)
	s = s - me
	ans = me + s / (m - 1)
	print('%.9f' % ans)


ans = []
for t in range(int(input())):
	n = int(input())
	numbers = list(map(int, input().split()))
	fs = max(numbers)
	ss = (sum(numbers) - fs) / (n - 1)
	ans.append(fs + ss)
for i in ans:
	print(i)


for q in range(int(input())):
	n = int(input())
	s = input()
	l = list(map(int, s.split()))
	maxi = l[0]
	sumi = 0
	for i in range(n):
		sumi += l[i]
		if maxi < l[i]:
			maxi = l[i]
	sumi = sumi - maxi
	ans = maxi + sumi / (n - 1)
	print('%.9f' % ans)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split(' ')))
	ma = max(l)
	s = sum(l)
	print(ma + (s - ma) / (n - 1))


t = int(input())
for t1 in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	su = sum(li)
	mx = max(li)
	print(mx + (su - mx) / (n - 1))


import sys
getline = sys.stdin.readline

def read_int():
	return int(getline())

def read_ints():
	return list(map(int, getline().split()))
t = read_int()
for _ in range(t):
	n = read_int()
	a = sorted(read_ints())
	avg = sum(a[:-1]) / (n - 1)
	print(a[-1] + avg)


t = int(input())
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	a = max(array)
	array.remove(a)
	b = sum(array) / (n - 1)
	print(a + b)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	j = a.pop(a.index(max(a)))
	j += sum(a) / len(a)
	print(f'{j:.9f}')


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort(reverse=True)
	(lsize, lsum, rsize, rsum) = (0, 0, n, sum(arr))
	i = 0
	ans = -1 * float('inf')
	while i < n - 1:
		lsize += 1
		lsum += arr[i]
		rsum -= arr[i]
		rsize -= 1
		curr = lsum / lsize + rsum / rsize
		ans = max(ans, curr)
		if arr[i + 1] < 1:
			break
		i += 1
	print(ans)


import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	ans = sum(a[:-1]) / (n - 1) + a[-1]
	ANS.append(str(ans))
print('\n'.join(ANS))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	sum_a = sum(a)
	max_a = max(a)
	print(max_a + (sum_a - max_a) / (n - 1))


t = int(input())
res = []
for i in range(t):
	n = int(input())
	a = input().split()
	for j in range(0, len(a)):
		a[j] = int(a[j])
	m = max(a)
	s = sum(a) - m
	av1 = s / (len(a) - 1)
	av2 = m
	s = av1 + av2
	res.append(s)
for t in res:
	print(t)


from sys import stdin, stdout
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as df, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = max(a)
	ans = sum(a) - x
	print('%0.8f' % (ans / (n - 1) + x))


t = int(input())
for _ in range(t):
	y = int(input())
	l = list(map(int, input().split()))
	m = max(l)
	avg = float((sum(l) - m) / (y - 1) + m)
	print(avg)


for s in [*open(0)][2::2]:
	a = [int(i) for i in s.split()]
	a.sort()
	print(sum(a[:-1]) / (len(a) - 1) + a[-1])


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def main(t):
	n = int(input())
	arr = list(map(int, input().split()))
	maximum = max(arr)
	tot = sum(arr)
	ans = maximum + (tot - maximum) * 1.0 / (n - 1)
	print(ans)
T = int(input())
t = 1
while t <= T:
	main(t)
	t += 1


v = []
t = int(input())
for ti in range(t):
	n = int(input())
	x = [int(x) for x in input().split()]
	s = (sum(x) - max(x)) / (n - 1)
	v.append(s + max(x))
for j in range(t):
	print(v[j])


def z(lst):
	return sum(lst) / len(lst)
a = int(input())
b = 0
while b < a:
	c = int(input())
	d = input()
	d = d.split(' ')
	e = list(map(int, d))
	f = max(e)
	e.remove(max(e))
	print(f + z(e))
	b = b + 1


t = int(input())
for j in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	a = l[n - 1]
	l.pop(n - 1)
	r = sum(l) / len(l) + a
	print(round(r, 9))


t = int(input())
for i in range(t):
	n = int(input())
	val = list(map(int, input().split()))
	a = max(val)
	b = (sum(val) - a) / (n - 1)
	print(a + b)


for g in [*open(0)][2::2]:
	a = list(map(int, g.split()))
	m = max(a)
	print((sum(a) - m) / (len(a) - 1) + m)


def game():
	n = int(input())
	k = n - 1
	arr = input()
	l = list(map(int, arr.split(' ')))
	sums = sum(l)
	maxt = max(l)
	ans = maxt + (sums - maxt) / k
	print(ans)
t = int(input())
while t:
	game()
	t -= 1


tc = int(input())
for t in range(tc):
	n = int(input())
	arr = list(map(int, input().split()))
	max_ = max(arr)
	sum_ = sum(arr)
	print(max_ + (sum_ - max_) / (n - 1))


for _ in range(int(input())):
	length = int(input())
	array = list(map(int, input().split()))
	max_num = max(array)
	array1 = [max(array)]
	array.remove(max_num)
	print(sum(array1) / len(array1) + sum(array) / len(array))


for _ in range(int(input())):
	n = int(input())
	arr = sorted(map(int, input().split()))
	m = (sum(arr) - arr[-1]) / (len(arr) - 1)
	print(m + arr[-1])


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	mx = max(l)
	print(mx + (sum(l) - mx) / (n - 1))


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	m = max(l)
	l.remove(m)
	ans = m + sum(l) / (n - 1)
	print(ans)


def checkpallidrome(i):
	if i[0::1] == i[-1::-1]:
		return True
	else:
		return False

def uniquebid(l):
	d = {}
	m = 10000
	index = 0
	for i in range(len(l)):
		d[l[i]] = d.get(l[i], 0) + 1
	for i in range(len(l)):
		if m > l[i] and d[l[i]] == 1:
			m = l[i]
			index = i + 1
	if index != 0:
		return index
	return -1

def remove_zero(n):
	while n % 10 == 0:
		n = n / 10
	return int(n)

def count_digit(n):
	co = 0
	while n > 0:
		co = co + 1
		n = n // 10
	return co

def most_frequent(List):
	return max(set(List), key=List.count)

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)
c = int(input())
for j in range(c):
	n = int(input())
	l = list(map(int, input().strip().split()))
	m = l[0]
	b = 0
	for i in range(n):
		if m < l[i]:
			m = l[i]
		b = b + l[i]
	print((b - m) / (n - 1) + m)


def findAns(arr):
	arr.sort()
	res = -1000000000000.0
	sums = 0.0
	tot = sum(arr)
	x = 0.0
	n = len(arr)
	for i in range(len(arr) - 1):
		sums += arr[i]
		x += 1
		res = max(res, round(sums / x + (tot - sums) / (n - x), 10))
	return res
T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	print(findAns(arr))


for t in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split(' ')]
	answer = max(a)
	a.remove(answer)
	answer += sum(a) / len(a)
	print(answer)


import heapq
import sys
from math import *
import threading
from heapq import *
from itertools import count
from pprint import pprint
from collections import defaultdict
from heapq import heapify, heappop, heappush
mod = 10 ** 9 + 7
inf = 10 ** 15
decision = ['NO', 'YES']
yes = 'YES'
no = 'NO'
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

	def npr(self, n, k):
		if k < 0 or n < k:
			return 0
		f = self.factorial
		return f.calc(n) * f.invFactorial(n - k) % self.MOD

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: max(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

def lower_bound(li, num):
	answer = len(li)
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = len(li)
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			start = middle + 1
		else:
			answer = middle
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val):
	ans = -1
	lb = 0
	ub = len(li) - 1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [li[0]]
	for i in range(1, len(li)):
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def SieveOfEratosthenes(n):
	prime = [{1, i} for i in range(n + 1)]
	p = 2
	while p <= n:
		for i in range(p * 2, n + 1, p):
			prime[i].add(p)
		p += 1
	return prime

def primefactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n //= 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n //= i
	if n > 2:
		factors.append(n)
	return factors

def prod(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def given():
	a = list(map(int, input().split()))
	return a

def givenString():
	s = list(input())
	return s

def givenStringInt():
	s = [int(x) for x in givenString()]
	return s

def main():
	karmanya = given()[0]
	while karmanya != 0:
		karmanya -= 1
		n = given()[0]
		a = given()
		s = sum(a)
		mm = max(a)
		ans = mm + (s - mm) / (n - 1)
		print('%.9f' % ans)
main()


from sys import stdin
t = int(stdin.readline())
for _ in range(0, t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	a.sort()
	r = sum(a)
	l = 0
	avg = -1e+17
	for i in range(0, n - 1):
		l += a[i]
		r -= a[i]
		_avg = l / (i + 1) + r / (n - i - 1)
		avg = max(avg, _avg)
	print(avg)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	avg_left = sum(arr[0:n - 1]) / (n - 1)
	res = avg_left + arr[n - 1]
	print(res)


m = int(input())
for _ in range(m):
	n = int(input())
	a = list(map(int, input().split()))
	z = max(a)
	print(z + (sum(a) - z) / (n - 1))


t = int(input())

def split_list(a):
	size = len(a)
	res = []
	for i in range(2 ** size + 1, 2 ** (size + 1) - 1):
		A = []
		B = []
		mask = bin(i)
		mask = str(mask)[3:]
		for (i, c) in enumerate(mask):
			if c == '0':
				A.append(a[i])
			else:
				B.append(a[i])
		res.append([A, B])
	return res
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	biggest = max(a)
	a.remove(biggest)
	print(biggest + sum(a) / len(a))


t = int(input())
for _ in range(t):
	n = int(input())
	ls = list(map(int, input().split(' ')))
	s = sum(ls)
	m = max(ls)
	res = m + (s - m) / (n - 1)
	print(format(res, '.11f'))


from itertools import permutations, combinations, combinations_with_replacement
from bisect import bisect_left, bisect_right
from typing import List
from math import ceil, floor, gcd, sqrt
from itertools import accumulate
tt = int(input())
for _ in range(tt):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort(reverse=True)
	_avg = lst[0]
	b = lst[1:]
	b_size = n - 1
	_avg += sum(b) / b_size
	print('{0:.9f}'.format(_avg))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	print(sum(a[:-1]) / (n - 1) + a[-1])


T = int(input())
while T > 0:
	N = int(input())
	lst = input().split()
	lst = list(map(int, lst))
	MAX = max(lst)
	SUM = sum(lst) - MAX
	LEN = len(lst) - 1
	F1 = SUM / LEN
	ANS = F1 + MAX
	print('%.9f' % ANS)
	T = T - 1