Yelisey has an array $a$ of $n$ integers.

If $a$ has length strictly greater than $1$, then Yelisei can apply an operation called minimum extraction to it:

First, Yelisei finds the minimal number $m$ in the array. If there are several identical minima, Yelisey can choose any of them.

Then the selected minimal element is removed from the array. After that, $m$ is subtracted from each remaining element.

Thus, after each operation, the length of the array is reduced by $1$.

For example, if $a = [1, 6, -4, -2, -4]$, then the minimum element in it is $a_3 = -4$, which means that after this operation the array will be equal to $a=[1 {- (-4)}, 6 {- (-4)}, -2 {- (-4)}, -4 {- (-4)}] = [5, 10, 2, 0]$.

Since Yelisey likes big numbers, he wants the numbers in the array $a$ to be as big as possible.

Formally speaking, he wants to make the minimum of the numbers in array $a$ to be maximal possible (i.e. he want to maximize a minimum). To do this, Yelisey can apply the minimum extraction operation to the array as many times as he wants (possibly, zero). Note that the operation cannot be applied to an array of length $1$.

Help him find what maximal value can the minimal element of the array have after applying several (possibly, zero) minimum extraction operations to the array.


-----Input-----

The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The next $2t$ lines contain descriptions of the test cases.

In the description of each test case, the first line contains an integer $n$ ($1 \leq n \leq 2 \cdot 10^5$) — the original length of the array $a$. The second line of the description lists $n$ space-separated integers $a_i$ ($-10^9 \leq a_i \leq 10^9$) — elements of the array $a$.

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


-----Output-----

Print $t$ lines, each of them containing the answer to the corresponding test case. The answer to the test case is a single integer — the maximal possible minimum in $a$, which can be obtained by several applications of the described operation to it.


-----Examples-----

Input
8
1
10
2
0 0
3
-1 2 0
4
2 10 1 7
2
2 3
5
3 2 -4 -2 0
2
-1 1
1
-2
Output
10
0
2
5
2
2
2
-2


-----Note-----

In the first example test case, the original length of the array $n = 1$. Therefore minimum extraction cannot be applied to it. Thus, the array remains unchanged and the answer is $a_1 = 10$.

In the second set of input data, the array will always consist only of zeros.

In the third set, the array will be changing as follows: $[\color{blue}{-1}, 2, 0] \to [3, \color{blue}{1}] \to [\color{blue}{2}]$. The minimum elements are highlighted with $\color{blue}{\text{blue}}$. The maximal one is $2$.

In the fourth set, the array will be modified as $[2, 10, \color{blue}{1}, 7] \to [\color{blue}{1}, 9, 6] \to [8, \color{blue}{5}] \to [\color{blue}{3}]$. Similarly, the maximum of the minimum elements is $5$.

Difficulty: EASY
Tags: Sorting

Complete search
Skill types: Sorting

Complete search

Starter code:

Solutions:
def solve(a, n):
	a.sort()
	ans = a[0]
	for i in range(1, n):
		ans = max(ans, a[i] - a[i - 1])
	return ans
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(a, n))


def minExtraction(array):
	if len(array) == 1:
		return array[0]
	minel = min(array)
	array.sort()
	n = len(array)
	window = 0
	for x in range(1, n):
		if array[x] - array[x - 1] > window:
			window = array[x] - array[x - 1]
	return max(window, minel)
t = int(input())
final = []
for _ in range(t):
	n = int(input())
	array = list(map(int, input().split()))
	final.append(minExtraction(array))
for _ in range(t):
	print(final[_])


for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split()))) + [-1000000000]
	m = 0
	if n == 1:
		print(arr[0])
		continue
	s = 0
	c = 0
	m = arr[0]
	for i in range(n):
		c += arr[i] - c
		if arr[i + 1] - c > m:
			m = arr[i + 1] - arr[i]
	print(m)


import sys
input = sys.stdin.readline
print = sys.stdout.write
for _ in range(int(input())):
	_ = input()
	a = [0] + sorted(map(int, input().split()))
	best = -9999999999
	for i in range(1, len(a)):
		best = max(best, a[i] - a[i - 1])
	print(str(best) + '\n')


def main():
	n = int(input())
	array = sorted([int(x) for x in input().split()])
	(mx, sm) = (array[0], array[0])
	for i in range(1, n):
		cnt = array[i] - sm
		sm += cnt
		mx = max(mx, cnt)
	print(mx)
tests = int(input())
while tests > 0:
	tests -= 1
	main()


def function(l):
	out = []
	for case in l:
		case.sort()
		temp = [case[0]]
		if len(case) != 1:
			for i in range(1, len(case)):
				e = case[i] - case[i - 1]
				temp.append(e)
		out.append(str(max(temp)))
	return '\n'.join(out)
t = int(input())
l = []
for i in range(t):
	n = input()
	e = list(map(int, input().split()))
	l.append(e)
ans = function(l)
print(ans)


import sys
num_test = int(sys.stdin.readline())
for it in range(1, num_test + 1):
	array_length = int(sys.stdin.readline())
	array = [int(x) for x in sys.stdin.readline().split()]
	array.sort()
	max_delta = array[0]
	for i in range(array_length - 1):
		max_delta = max(array[i + 1] - array[i], max_delta)
	print(max_delta)


test = int(input())
listout = []
while test > 0:
	n = int(input())
	a1 = list(map(int, input().strip().split()))[:n]
	a1.sort()
	a2 = [a1[0]]
	for x in range(n - 1):
		a2.append(a1[x + 1] - a1[x])
	listout.append(max(a2))
	test = test - 1
print(*listout, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	aaa = list(map(int, input().split()))
	aaa.sort()
	go = True
	s = 0
	b = aaa[0]
	bm = b
	for j in range(1, n):
		s -= aaa[j - 1] + s
		if aaa[j] + s > bm:
			bm = aaa[j] + s
	print(bm)


t = int(input())
while t > 0:
	ma = 0
	a = int(input())
	l = list(map(int, input().split()))
	mn = min(l)
	l.sort()
	for i in range(0, len(l) - 1, 1):
		mn = max(mn, l[i + 1] - l[i])
	print(mn)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	list_a = list(map(int, input().split()))
	list_a.sort()
	maximum_minimal = list_a[0]
	minus = 0
	if len(list_a) == 1:
		maximum_minimal = list_a[0]
	for j in range(len(list_a) - 1):
		m = list_a[j + 1] - list_a[j]
		if m > maximum_minimal:
			maximum_minimal = m
	print(maximum_minimal)


def get_ans(n, a):
	max_min = -10000000000
	already_deleted_sum = 0
	a.sort()
	for _i in range(len(a)):
		i = a[_i]
		i -= already_deleted_sum
		max_min = max(max_min, i)
		already_deleted_sum += i
	return max_min
anss = []
t = int(input())
for _ in range(t):
	_n = int(input())
	_a = list(map(int, input().split()))
	anss.append(get_ans(_n, _a))
for ans in anss:
	print(ans)


for _ in range(int(input())):
	N = int(input())
	arr = list(map(int, input().split()))
	if len(arr) == 1:
		print(arr[0])
		continue
	arr.sort()
	for i in range(len(arr) - 1, 0, -1):
		arr[i] -= arr[i - 1]
	print(max(arr))


number_tests = int(input())
for test in range(number_tests):
	list_size = int(input())
	list_values = input().split()
	list_values = list(map(int, list_values))
	list_values.sort()
	lowest = 0
	previous = 0
	is_first = True
	for value in list_values:
		if is_first:
			is_first = False
			lowest = value
			previous = lowest
		else:
			diff = value - previous
			if diff > lowest:
				lowest = diff
			previous = value
	print(lowest)


from sys import stdin, stdout
t = int(stdin.readline())
for tt in range(t):
	n = int(stdin.readline())
	a = [int(s) for s in stdin.readline().split()]
	a.sort()
	mx = a[0]
	subed = 0
	for i in range(n):
		ai = a[i] - subed
		if ai > mx:
			mx = ai
		subed += ai
	print(mx)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if n == 1:
		print(arr[0])
	else:
		temp = arr[0]
		for i in range(1, len(arr)):
			arr[i] -= temp
			temp += arr[i]
		print(max(arr))


from collections import defaultdict as d

def solve():
	n = int(input())
	ll = list(map(int, input().split()))
	if n == 1:
		return ll[0]
	ans = -9999999999
	temp_sum = 0
	ll.sort()
	for i in range(n - 1):
		x = ll[i] - temp_sum
		temp_sum += x
		ans = max(ans, x)
	ans = max(ans, ll[-1] - temp_sum)
	return ans
t = int(input())
while t != 0:
	res = solve()
	print(res)
	t -= 1


from __future__ import division, print_function
import os
import sys
from fileinput import input
from io import BytesIO, IOBase
import math
import heapq
inf = float('inf')
mod = 1000000007
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():

	def solve():
		n = int(input())
		arr = list(map(int, input().split()))
		heapq.heapify(arr)
		ans = arr[0]
		x = 0
		while len(arr) > 1:
			temp = heapq.heappop(arr)
			ans = max(ans, temp - x)
			x += temp - x
		ans = max(ans, arr[0] - x)
		print(ans)
	t = int(input())
	for i in range(t):
		solve()
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')
main()


from time import time
_START_TIME_ = time()
_DEBUGGING_ = False

def read_line() -> str:
	if _DEBUGGING_:
		return _fr_.readline()
	else:
		return input()

def write(*args, _sep=' ', _end='\n'):
	if _DEBUGGING_:
		_fw_.write(f'{_sep.join((str(elem) for elem in args))}{_end}')
	else:
		print(*args, sep=_sep, end=_end)

def log(*args, _sep=' ', _end='\n'):
	if _DEBUGGING_:
		print(*args, sep=_sep, end=_end)

def solve(n, arr):
	arr.sort()
	sub = 0
	max_min = arr[0]
	for a in arr:
		max_min = max(max_min, a - sub)
		sub = a
	write(max_min)
if _DEBUGGING_:
	_fr_ = open('input.txt')
	_fw_ = open('output.txt', 'w')
_t_ = int(read_line().strip())
for _ in range(_t_):
	_n_ = int(read_line().strip())
	_arr_ = [int(x) for x in read_line().strip().split()]
	solve(_n_, _arr_)
if _DEBUGGING_:
	_fr_.close()
	_fw_.close()
if _DEBUGGING_:
	print('\nElapsed time: {:.2f}s'.format(time() - _START_TIME_), end='')


a = int(input())
res = []
for i in range(a):
	k = int(input())
	n = input().split()
	for i in range(k):
		n[i] = int(n[i])
	n = sorted(n)
	m = n[0]
	for i in range(k - 1):
		if n[i + 1] - n[i] > m:
			m = n[i + 1] - n[i]
	res.append(m)
for i in res:
	print(i)


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')
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split(' ')))
	if 1 == n:
		M = A[0]
	else:
		A.sort()
		(M, s) = (A[0], 0)
		for a in A:
			M = max(M, a - s)
			s += a - s
	print(M)


n = int(input())
for x in range(n):
	tmp1 = int(input())
	tmp2 = list(map(int, input().split()))
	if tmp1 == 1:
		print(*tmp2)
		continue
	tmp2.sort()
	lst = tmp2[0]
	for x in range(1, tmp1):
		if tmp2[x] - tmp2[x - 1] > lst:
			lst = tmp2[x] - tmp2[x - 1]
	print(lst)


import math
T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(a[0])
		continue
	a.sort()
	neg = 0
	i = 0
	rem = 0
	pos = 0
	ans = -999999999
	while i < n:
		ans = max(ans, a[i] + abs(neg) - pos)
		if a[i] + abs(neg) - pos < 0:
			neg += a[i] + neg
		else:
			pos += a[i] + abs(neg) - pos
		i += 1
	print(ans)


t = int(input())
while t > 0:
	n = int(input())
	l = [int(x) for x in input().split()]
	if n == 1:
		print(l[0])
	else:
		l.sort()
		max = l[0]
		for i in range(n - 1):
			if max < l[i + 1] - l[i]:
				max = l[i + 1] - l[i]
		print(max)
	t = t - 1


t = int(input())
DIC = {}
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	i = 0
	tot = 0
	mx = lst[0]
	while i < n:
		mx = max(mx, lst[i] - tot)
		tot += lst[i] - tot
		i += 1
	print(mx)


import sys
import math
import random
import heapq
input = sys.stdin.readline

def pow(a, n):
	if n == 0:
		return 1
	x = pow(a, n // 2)
	if n % 2 == 0:
		return x * x
	else:
		return x * x * a

def gcd(a, b):
	while b != 0:
		(a, b) = (b, a % b)
	return a

def bs(arr, le, ri):
	l = 0
	arr.sort()
	r = len(arr) - 1
	ans = 10000000
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= le and arr[m] <= ri:
			ans = arr[m]
			r = m - 1
		elif arr[m] < le:
			l = m + 1
		else:
			r = m - 1
	return ans
t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = l[0]
	s = l[0]
	for i in l[1:]:
		ans = max(ans, i - s)
		s = i
	print(ans)
	t -= 1


n = int(input())
for _ in range(n):
	_2 = input()
	x = list(map(int, input().split()))
	x = sorted(x)
	last = x[0]
	max_ = x[0]
	for i in x[1:]:
		if i - last > max_:
			max_ = i - last
		last = i
	print(max_)


t = int(input())
inf = -10 ** 17
ans = []
for _ in range(t):
	n = int(input())
	nums = [int(_) for _ in input().split()]
	nums.sort()
	val = nums[0]
	pre = nums[0]
	flag = True
	for n in nums[1:]:
		(val, pre) = (max(val, n - pre), n)
	ans.append(str(val))
print('\n'.join(ans))


t = int(input())
for i in range(t):
	n = int(input())
	araye = input().split()
	for ii in range(n):
		araye[ii] = int(araye[ii])
	araye.sort()
	mini = araye[0]
	for j in range(n - 1):
		if araye[j + 1] - araye[j] > mini:
			mini = araye[j + 1] - araye[j]
	print(mini)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	m = a[0]
	if n > 1:
		for i in range(n - 1):
			if a[i + 1] - a[i] > m:
				m = a[i + 1] - a[i]
	print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	nums.sort()
	max_min = float('-inf')
	cur = 0
	for i in range(n):
		new = nums[i] + cur
		max_min = max(max_min, new)
		cur -= new
	print(max_min)


import heapq
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	heapq.heapify(a)
	ans = heapq.heappop(a)
	keep = ans
	while n > 1:
		b = heapq.heappop(a)
		ans = max(ans, b - keep)
		keep = b
		n -= 1
	print(ans)


for _ in range(int(input())):
	n = int(input())
	ans = -10000000000.0
	if n == 1:
		ans = input()
	else:
		arr = list(map(int, input().split()))
		arr.sort()
		ans = arr[0]
		for i in range(1, n):
			h = arr[i] - arr[i - 1]
			if ans <= h:
				ans = h
	print(ans)


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def minimumExtraction():
	n = inp()
	a = sorted(inlt())
	diff = 0
	ret = a[0]
	for i in range(len(a)):
		ret = max(ret, a[i] - diff)
		diff += a[i] - diff
	print(ret)
	return
t = inp()
for i in range(t):
	minimumExtraction()


import sys
DEBUG_ENABLED = True

def debug(*args, **kwargs):
	if DEBUG_ENABLED:
		print(*args, file=sys.stderr, **kwargs)

def solve_case(case_num: int, length: int, array: list) -> str:
	array.sort()
	ma_mi = array[0]
	variable = 0
	for pos in range(len(array)):
		array[pos] = array[pos] - variable
		variable += array[pos]
		if array[pos] > ma_mi:
			ma_mi = array[pos]
	return ma_mi
T = int(input())
for tt in range(T):
	n1 = int(input())
	array1 = list(map(int, input().split()))
	if n1 == 1:
		print(array1[0])
		continue
	result = solve_case(tt + 1, n1, array1)
	print(result)
pass


for i in range(int(input())):
	length = int(input())
	full_list = [*map(lambda x: int(x), input().split())]
	if len(full_list) == 1:
		print(min(full_list))
	else:
		full_list.sort()
		differences = [j - i for (i, j) in zip(full_list[:-1], full_list[1:])]
		differences.append(full_list[0])
		print(max(differences))


def minimal(a):
	if len(a) == 1:
		return a[0]
	a.sort()
	f = [0] * len(a)
	f[0] = a[0]
	s = f[0]
	for i in range(1, len(a)):
		f[i] = a[i] - s
		s += f[i]
	return max(f)
t = int(input())
for qwer in range(t):
	n = int(input())
	stro = list(map(int, input().split()))
	print(minimal(stro))


import sys
import os
import math
import bisect
from collections import *
import heapq
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from itertools import *
from functools import *
import random
sys.setrecursionlimit(100000000)
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
INF = float('inf')
MOD = 1000000007
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 solve():
	n = inp()
	arr = seq()
	ans = -INF
	ptr = 0
	arr.sort()
	prev = 0
	for i in range(n):
		ans = max(ans, arr[i] - prev)
		prev += arr[i] - prev
	print(ans)
t = 1
t = inp()
for _ in range(t):
	solve()


import sys
input = sys.stdin.readline

def solve():
	N = int(input())
	A = list(map(int, input().split()))
	if N == 1:
		print(A[0])
	else:
		A.sort()
		print(max(A[0], max((y - x for (x, y) in zip(A, A[1:])))))
for _ in range(int(input())):
	solve()


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	a = [int(x) for x in sys.stdin.readline().split()]
	if len(a) == 1:
		print(a[0])
		continue
	a.sort()
	m = a[0]
	for i in range(1, len(a)):
		m = max(m, a[i] - a[i - 1])
	print(m)


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	l = list(map(int, sys.stdin.readline().split()))
	if n <= 1:
		print(l[0])
	else:
		l.sort()
		s = l[0]
		v = [l[0]]
		for i in range(1, n):
			v.append(l[i] - s)
			s = s + v[i]
		print(max(v))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	for i in range(n - 1, 0, -1):
		a[i] -= a[i - 1]
	print(max(a))


for _ in range(int(input())):
	n = int(input())
	li = sorted(list(map(int, input().split()[:n])))
	ans = li[0]
	for i in range(n - 1):
		if li[i + 1] - li[i] > ans:
			ans = li[i + 1] - li[i]
	print(ans)


import sys
import time
import os
from io import BytesIO, IOBase
import math
from random import randint
M = 10 ** 9 + 7
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')

def inputf():
	return sys.stdin.readline().rstrip('\r\n')

def get_ints():
	return list(map(int, inputf().split()))

def get_string():
	return list(map(str, inputf().split()))
global maximum

def _lis(arr, n):
	global maximum
	if n == 1:
		return 1
	maxEndingHere = 1
	for i in range(1, n):
		res = _lis(arr, i)
		if arr[i - 1] < arr[n - 1] and res + 1 > maxEndingHere:
			maxEndingHere = res + 1
	maximum = max(maximum, maxEndingHere)
	return maxEndingHere

def LIS(arr):
	global maximum
	n = len(arr)
	maximum = 1
	_lis(arr, n)
	return maximum

def binary_search(data, elem):
	low = 0
	high = len(data) - 1
	while low <= high:
		middle = (low + high) // 2
		if data[middle] == elem:
			return middle
		elif data[middle] > elem:
			high = middle - 1
		else:
			low = middle + 1
	return middle

def upper_bound(my_list, key):
	large = len(my_list) - 1
	small = 0
	while small <= large:
		mid = (small + large) // 2
		if my_list[mid] < key:
			small = mid + 1
		elif my_list[mid] > key:
			large = mid - 1
		else:
			return mid
	if my_list[mid] > key:
		return mid
	else:
		return mid + 1

def lower_bound(my_list, key):
	large = len(my_list) - 1
	small = 0
	while small <= large:
		mid = (small + large) // 2
		if my_list[mid] < key:
			small = mid + 1
		elif my_list[mid] > key:
			large = mid - 1
		else:
			return mid
	if my_list[mid] < key:
		return mid
	else:
		return mid - 1
a = []

def SieveOfEratosthenes(n):
	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]:
			a.append(p)

def roman_number(x):
	if x > 15999:
		return
	value = [5000, 4000, 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
	symbol = ['F', 'MF', 'M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
	roman = ''
	i = 0
	while x > 0:
		div = x // value[i]
		x = x % value[i]
		while div:
			roman += symbol[i]
			div -= 1
		i += 1
	return roman

def maxSubArraySum(a, size):
	max_so_far = a[0]
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_ending_here < 0:
			max_ending_here = 0
		elif max_so_far < max_ending_here:
			max_so_far = max_ending_here
	return max_so_far

def prefixSum(test_list):
	res = [sum(test_list[:i + 1]) for i in range(len(test_list))]
	return res

def lcm(x, y):
	if x > y:
		greater = x
	else:
		greater = y
	while True:
		if greater % x == 0 and greater % y == 0:
			lcm = greater
			break
		greater += 1
	return lcm
testcase = int(inputf())
for test in range(testcase):
	n = int(inputf())
	a = get_ints()
	a.sort()
	res = a[0]
	for i in range(1, n):
		res = max(res, a[i] - a[i - 1])
	print(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')
from collections import Counter, defaultdict
import math
import heapq
import bisect

def nck(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - i + 1) // i
	return res
for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	a = 0
	if n == 1:
		print(arr[0])
	else:
		var = arr[0]
		ans = arr[0]
		for i in range(1, n):
			ans = max(ans, arr[i] - var)
			var += arr[i] - var
		print(ans)


import sys
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	x = a[0]
	h = a[0]
	for i in range(1, n):
		if a[i] - x > h:
			h = a[i] - x
		x += a[i] - x
	print(h)


import sys
from collections import deque
import heapq
import bisect
import copy
MOD = 1000000007
NO = lambda : print('NO')
YES = lambda : print('YES')
_1 = lambda : print(-1)
ari = lambda : [int(_) for _ in input().split()]
cin = lambda : int(input())
cis = lambda : input()
show = lambda x: print(x)
fast = lambda : sys.stdin.readline()
test_case = 1
test_case = int(input())
sys.setrecursionlimit(10 ** 6)

def ans():
	n = cin()
	arr = ari()
	if n == 1:
		print(*arr)
		return
	arr.sort()
	maxi = arr[0]
	for i in range(len(arr) - 1):
		maxi = max(maxi, arr[i + 1] - arr[i])
	print(maxi)
	return
for _ in range(test_case):
	ans()


import heapq
import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	if len(arr) == 1:
		print(arr[0])
	else:
		heapq.heapify(arr)
		ans = 0
		maxv = -math.inf
		while arr:
			m = heapq.heappop(arr)
			left = m - ans
			ans += m - ans
			maxv = max(maxv, left)
		print(maxv)


t = int(input())
while t:
	n = int(input())
	s = input()
	s = s.split(' ')
	for i in range(0, n):
		s[i] = int(s[i])
	s.sort()
	maxraz = 0
	if len(s) > 1:
		for i in range(1, len(s)):
			if s[i] - s[i - 1] > maxraz:
				maxraz = s[i] - s[i - 1]
		if maxraz > s[0]:
			print(maxraz)
		else:
			print(s[0])
	else:
		print(s[0])
	t -= 1


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		ans = a[0]
	else:
		a.sort()
		z = [0] * n
		z[0] = a[0]
		for i in range(1, n):
			z[i] = a[i] - a[i - 1]
		ans = max(z)
	print(ans)
	t -= 1


def main():
	t = int(input())
	for count in range(t):
		n = int(input())
		s = input().split()
		a = [int(i) for i in s]
		a.sort()
		b = [0] * n
		b[0] = a[0]
		sum = a[0]
		max_min = a[0]
		for i in range(1, n):
			b[i] = a[i] - sum
			if max_min < b[i]:
				max_min = b[i]
			sum += b[i]
		print(max_min)
main()


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


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	k = [l[0]]
	for i in range(len(l) - 1):
		k.append(l[i + 1] - l[i])
	print(max(k))


for _ in range(int(input())):
	n = int(input())
	x = list(map(int, input().split()))
	if n == 1:
		ans = x[0]
	else:
		x = sorted(x)
		ans = x[0]
		for i in range(1, n):
			xd = x[i] - x[i - 1]
			if xd > ans:
				ans = xd
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(a[0])
		continue
	a.sort()
	ma_min = a[0]
	add = 0
	for v in a:
		if v + add > ma_min:
			ma_min = v + add
		add += -v - add
	print(ma_min)


for _ in range(1, int(input()) + 1):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	if n == 1:
		print(arr[0])
	else:
		maxi = arr[0]
		for i in range(len(arr) - 1):
			j = abs(arr[i] - arr[i + 1])
			maxi = max(maxi, j)
		print(maxi)


t = int(input())
for i in range(t):
	n = int(input())
	K = list(map(int, input().split()))
	K.sort()
	count = K[0]
	for i in range(n - 1):
		count = max(count, K[i + 1] - K[i])
	print(count)


def ans():
	n = int(input())
	a = list(map(int, input().split()))
	if n < 2:
		return min(a)
	a.sort()
	x = a[0]
	for i in range(1, len(a)):
		if abs(a[i - 1] - a[i]) > x:
			x = abs(a[i - 1] - a[i])
	return x
for _ in range(int(input())):
	print(ans())


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	ans = []
	ans.append(l[0])
	if n == 1:
		print(l[0])
	else:
		for i in range(n - 1):
			ans.append(l[i + 1] - l[i])
		print(max(ans))


t = int(input())
rjesenje = []
while t:
	n = int(input())
	niz = list(map(int, input().split()))
	niz.sort()
	najmanji = niz[0]
	for i in range(1, len(niz)):
		najmanji = max(najmanji, niz[i] - niz[i - 1])
	rjesenje.append(najmanji)
	t -= 1
for i in rjesenje:
	print(i)


def fun(nums):
	nums.sort()
	return max(nums[0], max((nums[i] - nums[i - 1] for i in range(1, len(nums)))) if len(nums) != 1 else nums[0] - 1)
t = int(input())
for _ in range(t):
	n = int(input())
	nums = [int(x) for x in input().split()]
	print(fun(nums))


import sys

def function(n, arr):
	arr = sorted(arr)
	maximum = arr[0]
	for i in range(1, n):
		maximum = max(maximum, arr[i] - arr[i - 1])
	return maximum

def main():
	t = int(sys.stdin.readline())
	for _ in range(t):
		n = int(sys.stdin.readline())
		arr = list(map(int, sys.stdin.readline().strip().split()))
		res = function(n, arr)
		print(res)
main()


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	mx = min(a)
	k = 0
	for i in range(len(a) - 1):
		mx = max(mx, a[i + 1] - a[i] + k)
		a[i + 1] = a[i + 1] - a[i] + k
		k -= a[i]
	print(mx)


import sys
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	arr = [int(c) for c in input().split()]
	arr.sort()
	ans = float('-inf')
	curr = 0
	for i in arr:
		s = i - curr
		ans = max(ans, s)
		curr = i
	print(ans)


def solve():
	n = int(input())
	l = input()
	l = [int(i) for i in l.split()]
	try:
		if n == 1:
			print(l[0])
			return
		elif n == 2:
			a = min(l)
			l.remove(a)
			a = max(a, l[0] - a)
			print(a)
			return
		else:
			l.sort()
			mx = l[0]
			for i in range(n - 1):
				mx = max(mx, l[i + 1] - l[i])
			print(mx)
	except EOFError as e:
		print('Error')
for case in range(int(input())):
	solve()


for s in [*open(0)][2::2]:
	a = sorted(map(int, s.split()))
	print(max((y - x for (x, y) in zip([0] + a, a))))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	li = [a[0]]
	for i in range(1, n):
		li.append(a[i] - a[i - 1])
	print(max(li))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = p = 0
	smax = a[0]
	for j in range(n - 1):
		k -= a[p]
		smax = max(smax, k + a[p + 1])
		a[p + 1] += k
		p += 1
	print(smax)


t = int(input())
for k in range(0, t, 1):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min = a[0]
	for i in range(1, n, 1):
		if a[i] - a[i - 1] > min:
			min = a[i] - a[i - 1]
	print(min)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	s = 0
	x = l[0]
	mn = x
	for i in range(n):
		x = l[i] - s
		s += x
		mn = max(x, mn)
	print(mn)


from sys import stdin, stdout, setrecursionlimit
from io import BytesIO, IOBase
from collections import Counter, deque as dq, defaultdict
setrecursionlimit(10000)

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
		self.BUFSIZE = 8192

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

	def readline(self):
		while self.newlines == 0:
			a = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, self.BUFSIZE))
			self.newlines = a.count(b'\n') + (not a)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(a), 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')
(stdin, stdout) = (IOWrapper(stdin), IOWrapper(stdout))
input = lambda : stdin.readline().rstrip('\r\n')
inp = lambda : int(input())
st = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
int_arr = lambda : list(map(int, input().strip().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().strip().split())
get_int = lambda : map(int, input().strip().split())
get_float = lambda : map(float, input().strip().split())
mod = 1000000007
for _ in range(inp()):
	n = inp()
	arr = int_arr()
	if n == 1:
		print(arr[0])
	else:
		arr.sort()
		ele = arr[0]
		tot = 0
		mx = arr[0]
		for i in range(1, n):
			arr[i] -= ele + tot
			tot += ele
			mx = max(arr[i], mx)
			ele = arr[i]
		print(mx)


def main():
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 1:
		return arr[0]
	arr.sort()
	mx = arr[0]
	for i in range(n - 1):
		if arr[i + 1] - arr[i] > mx:
			mx = arr[i + 1] - arr[i]
	return mx
for _ in range(int(input())):
	print(main())


for i in range(int(input())):
	n = int(input())
	arr = [int(num) for num in input().split(' ')]
	arr.sort()
	s = 0
	newArr = [arr[0]]
	j = 1
	for j in range(len(arr) - 1):
		newArr.append(arr[j + 1] - arr[j])
	print(max(newArr))


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst.sort()
	if len(lst) == 1:
		print(lst[0])
		continue
	big = 0
	for i in range(1, n):
		if lst[i] - lst[i - 1] > big:
			big = lst[i] - lst[i - 1]
	print(max(big, lst[0]))


from heapq import *
t = int(input())

def solve(n, a, idx, offset):
	mins = []
	heap = a
	heapify(heap)
	offset = 0
	while len(heap) != 1:
		mins.append(heappop(heap) - offset)
		offset += mins[-1]
	mins.append(heap[0] - offset)
	return max(mins)
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	print(solve(n, a, 0, 0))


t = int(input())
for o in range(t):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	arr = [l[0]]
	for i in range(n - 1):
		arr += [l[i + 1] - l[i]]
	if arr == []:
		print(l[0])
	else:
		r = max(arr)
		print(r)


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	arr = list(map(int, stdin.readline().split()))
	ans = []
	arr.sort()
	s = 0
	for i in arr:
		i -= s
		ans.append(i)
		s += i
	print(max(ans))


b = int(input())
while b:
	b = b - 1
	n = int(input())
	k = list(map(int, input().split()))
	k.sort()
	ans = k[0]
	if n == 1:
		print(ans)
	else:
		for i in range(1, n):
			ans = max(ans, k[i] - k[i - 1])
		print(ans)


from sys import stdin, stdout
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	if n == 1:
		print(li[0])
		continue
	li.sort()
	ans = li[0]
	for i in range(1, n):
		ans = max(ans, li[i] - li[i - 1])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(a[0])
	else:
		a.sort()
		p = a[0]
		k = a[0]
		a[0] = 0
		for index in range(1, n):
			z = a[index]
			a[index] -= k
			k = z
		print(max(max(a), p))


t = int(input())
for _ in range(t):
	n = int(input())
	mass = list(map(int, input().split()))
	if n == 1:
		print(*mass)
		continue
	mass = sorted(mass)
	ans = [mass[0], mass[1] - mass[0]]
	i = 2
	while i < n:
		ans.append(mass[i] - mass[i - 1])
		i += 1
	print(max(ans))


t = int(input())
for i in range(0, t):
	n = int(input())
	lst = list(map(int, input().split()))
	lst2 = []
	if n == 1:
		print(lst[0])
	else:
		lst2.append(min(lst))
		lst.sort()
		for a in range(1, n):
			lst2.append(lst[a] - lst[a - 1])
		print(max(lst2))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	if n == 1:
		print(a[0])
	else:
		ans = min(a)
		for i in range(len(a) - 1, -1, -1):
			ans = max(ans, a[i] - a[i - 1])
		print(ans)


T = int(input())
for _ in range(T):
	N = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if len(l) == 1:
		print(l[0])
		continue
	if l[0] >= 0:
		l.insert(0, 0)
	max_val = 0
	for j in range(len(l) - 1):
		if l[j + 1] - l[j] > max_val:
			max_val = l[j + 1] - l[j]
	print(max_val)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 1:
		print(*l)
		continue
	l.sort()
	sum = l[0]
	for i in range(1, n):
		if l[i] - l[i - 1] > sum:
			sum = l[i] - l[i - 1]
	print(sum)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = [int(num) for num in input().split()]
	if n == 1:
		print(*a)
	else:
		m = min(a)
		if m < 0:
			del a[a.index(m)]
			a = [ai - m for ai in a]
			b = []
			c = []
			for ai in a:
				if ai < 0:
					b.append(abs(ai))
				else:
					c.append(ai)
			b = sum(b)
			a = [ci + b for ci in c]
		a.sort()
		max_min = a[0]
		minus = a[0]
		for ind in range(1, len(a)):
			max_min = max(max_min, a[ind] - minus)
			minus += a[ind] - minus
		print(max_min)


import sys
import heapq

def solve():
	T = int(sys.stdin.readline().rstrip())
	for _ in range(T):
		N = int(sys.stdin.readline().rstrip())
		S = list(map(int, sys.stdin.readline().rstrip().split(' ')))
		max_a = 2 * -10 ** 15
		stacked = 0
		heapq.heapify(S)
		while len(S) > 0:
			a = heapq.heappop(S)
			a += stacked
			stacked -= a
			if a > max_a:
				max_a = a
		print(max_a)
solve()


def main():
	T = int(input())
	for t in range(T):
		minimal()

def minimal():
	n = int(input())
	a = sorted(list(map(int, input().split(' '))), reverse=True)
	if n == 1:
		print(a[0])
		return
	a.append(0)
	subtractor = list((a[i] - a[i + 1] for i in range(len(a) - 1)))
	print(max(subtractor))
main()


import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(10 ** 5)
INF = 10 ** 18
import heapq

def solve():
	N = int(input())
	A = list(map(int, input().split()))
	if N == 1:
		print(A[0])
		return
	heapq.heapify(A)
	cnt = 1
	ans = heapq.heappop(A)
	add = ans
	while cnt < N:
		n = heapq.heappop(A)
		cnt += 1
		ans = max(ans, n - add)
		add += n - add
	print(ans)
Q = int(input())
for _ in range(Q):
	solve()


import sys
input = sys.stdin.readline
T = int(input())
result = []
for _ in range(T):
	_ = input()
	a = list(map(int, input()[:-1].split()))
	max_val = float(-float('inf'))
	sub_count = 0
	a.sort()
	if len(a) == 1:
		result.append(str(a[0]))
		continue
	for i in range(0, len(a) - 1):
		fst = a[i]
		max_val = max(max_val, fst)
		sub_count += fst
		a[i + 1] -= sub_count
	result.append(str(max(max_val, a[-1])))
print('\n'.join(result))


for _ in range(int(input())):
	x = int(input())
	x = list(map(int, input().split()))
	x.sort()
	v = [x[i + 1] - x[i] for i in range(len(x) - 1)]
	if len(v) == 1 and v[0] > x[0]:
		print(*v)
	elif len(v) == 0:
		print(*x)
	elif max(v) < x[0]:
		print(x[0])
	else:
		print(max(v))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(a[0])
		continue
	s = 0
	a.sort()
	mx = a[0]
	for i in range(n - 1):
		s -= a[i] + s
		mx = max(mx, a[i + 1] + s)
	print(mx)


t = int(input())
for test in range(t):
	n = int(input())
	p = list(map(int, input().split()))
	if len(p) == 1:
		print(p[0])
		continue
	elif len(p) == 2:
		print(max(min(p[0], p[1]), abs(p[0] - p[1])))
		continue
	ans = min(p)
	p.sort()
	for i in range(len(p) - 2, -1, -1):
		ans = max(ans, p[i + 1] - p[i])
	print(ans)


t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	min_ans = float('-inf')
	curr_sub = 0
	for i in arr:
		if i - curr_sub > min_ans:
			min_ans = i - curr_sub
		curr_sub += i - curr_sub
	print(min_ans)


t = int(input())
for q in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	lis = [arr[0]]
	for i in range(n - 1):
		lis.append(arr[i + 1] - arr[i])
	print(max(lis))


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	tot = a[0]
	for i in range(1, n):
		tot = max(tot, a[i] - a[i - 1])
	print(tot)


def findmin(a):
	if len(a) == 1:
		return a[0]
	else:
		a = sorted(a)
		minvalue = a[0]
		for i in range(len(a) - 1):
			minvalue = max(minvalue, a[i + 1] - a[i])
		return minvalue
t = int(input())
for i in range(t):
	n = int(input())
	if n == 1:
		print(input())
	else:
		a = list(map(int, input().split()))
		print(findmin(a))


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


import sys
readline = sys.stdin.readline
T = int(readline())
for t in range(T):
	N = int(readline())
	A = list(map(int, readline().split()))
	A = sorted(A)
	minus_sum = 0
	best = A[0]
	for i in range(N - 1):
		minus_sum += A[i]
		A[i + 1] -= minus_sum
		if A[i + 1] > best:
			best = A[i + 1]
	print(best)


from heapq import heapify, heappush, heappop, heappushpop
from collections import defaultdict as dd, deque as dq, Counter as C
from math import factorial as f, ceil, gcd, sqrt, log
from bisect import bisect_left as bl, bisect_right as br
from itertools import combinations as c, permutations as p
from math import factorial as f, ceil, gcd, sqrt, log
from sys import stdin
input = stdin.readline
mp = lambda : map(int, input().split())
it = lambda : int(input())
ls = lambda : list(input().strip().split())
mt = lambda r: [ls() for _ in range(r)]
lcm = lambda a, b: a * b // gcd(a, b)
for _ in range(it()):
	a = it()
	b = list(mp())
	b.sort()
	b = dq(b)
	tot = 0
	mx = b[0]
	while b:
		k = b.popleft()
		tot += k
		if b:
			mx = max(b[0] - tot, mx)
			b[0] -= tot
	print(mx)


def solve(arr):
	if len(arr) == 1:
		return arr[0]
	arr.sort()
	max = min(arr)
	for i in range(len(arr) - 1):
		if arr[i + 1] - arr[i] > max:
			max = arr[i + 1] - arr[i]
	return max
n = int(input())
out = []
for i in range(n):
	num = int(input())
	arr = input().split(' ')
	arr = [int(i) for i in arr]
	out.append(solve(arr))
for i in out:
	print(i)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split()
	for j in range(n):
		s[j] = int(s[j])
	s.sort()
	hieu = 0
	res = s[0]
	for i in range(1, n):
		s[i] = s[i] - hieu - s[i - 1]
		hieu += s[i - 1]
		res = max(res, s[i])
	print(res)


from os import path, truncate
from sys import int_info, stdin, stdout
if path.exists('tc.txt'):
	stdin = open('tc.txt', 'r')

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

def gms():
	return map(str, stdin.readline().strip().split())

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

def gart():
	return tuple(map(int, stdin.readline().strip().split()))

def gars():
	return list(map(str, stdin.readline().strip().split()))

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

def gls():
	return list(stdin.readline().strip())

def gi():
	return int(stdin.readline())
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(a[0])
		continue
	else:
		cnt = min(a)
		a.sort()
		n = len(a)
		for i in range(1, n):
			cnt = max(cnt, a[i] - a[i - 1])
		print(cnt)


T = int(input())
OUTPUT = []
for test in range(T):
	n = int(input())
	A = sorted([int(x) for x in input().split()])
	mimax = A[0]
	for i in range(n - 1):
		mimax = max(mimax, A[i + 1] - A[i])
	OUTPUT.append(mimax)
for result in OUTPUT:
	print(result)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	count = 0

	def solve(arr, n):
		if len(arr) == 1:
			return arr[0]
		arr = sorted(set(arr))
		res = min(arr)
		for i in range(len(arr) - 1):
			res = max(res, arr[i + 1] - arr[i])
		if res < 0:
			return 0
		return res
	print(solve(arr, n))


for _ in range(int(input())):
	n = int(input())
	x = sorted(list(map(int, input().split())))
	(cur, ans) = (x[0], x[0])
	for i in x[1:]:
		ans = max(ans, i - cur)
		cur += i - cur
	print(ans)


def minimize(l):
	if len(l) == 1:
		return l[0]
	l.sort()
	maxm = l[0]
	for i in range(len(l) - 1):
		d = l[i + 1] - l[i]
		maxm = max(d, maxm)
	return maxm
t = int(input())
cout = []
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	cout += [l]
print(*list(map(minimize, cout)), sep='\n')


import heapq as hq
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	hq.heapify(a)
	ans = a[0]
	ad = 0
	for i in range(n):
		x = hq.heappop(a) + ad
		ad -= x
		ans = max(ans, x)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(a[0])
		continue
	else:
		a.sort()
		m = a[0]
		for i in range(len(a) - 1):
			m = max(a[i + 1] - a[i], m)
		print(m)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	max_min = -10 ** 10
	d = 0
	for i in range(n):
		max_min = max(max_min, a[i] - d)
		d = a[i]
	print(max_min)


t = int(input())
for q in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(a[0])
	else:
		a.sort(reverse=True)
		d = [min(a)] + [a[i] - a[i + 1] for i in range(len(a) - 1)]
		print(max(d))


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 1:
		print(l[0])
	else:
		l.sort()
		temp = 0
		mini = [l[0]]
		for i in range(n - 1):
			temp = l[i]
			if l[i + 1] - temp > mini[0]:
				mini[0] = l[i + 1] - temp
		print(mini[0])


for t in range(int(input())):
	n = input()
	a = list(map(int, input().split()))
	m = -(10 ** 9 + 1)
	cum = 0
	cur = 0
	a.sort()
	for i in a:
		cur = i - cum
		if cur > m:
			m = cur
		cum += cur
	print(m)


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()))
	arr.sort()
	ans = arr[0]
	if n > 1:
		ans = max(ans, max([arr[i + 1] - arr[i] for i in range(n - 1)]))
	print(ans)
T = int(input())
t = 1
while t <= T:
	main(t)
	t += 1


import sys
import os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
	sys.stderr = open('error.txt', 'w')
depth = 1000000
mod = 1000000007
lim = mod * mod
sys.setrecursionlimit(depth)
linp = lambda : list(minp())
minp = lambda : map(int, input().split())
from math import inf, ceil, sqrt, log2, gcd
from collections import defaultdict, deque
dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
for _ in range(int(input())):
	n = int(input())
	a = sorted(linp())
	ans = a[0]
	for i in range(1, n):
		ans = max(ans, a[i] - a[i - 1])
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	if len(a) == 1:
		print(a[0])
	else:
		max = a[0]
		for i in range(n - 1):
			x = a[i + 1] - a[i]
			if x > max:
				max = x
		print(max)


t = int(input())
a = []
for _ in range(t):
	n = int(input())
	s = list(map(int, input().split()))
	s.sort()
	minus = 0
	ans = -10000000000000000000000000000000000000000000
	for i in range(n):
		ans = max(ans, s[i] - minus)
		minus = s[i]
	a.append(ans)
for elem in a:
	print(elem)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	if n == 1:
		print(lst[0])
	else:
		max_diff = 0
		lst.sort()
		for i in range(1, n):
			if lst[i] - lst[i - 1] > max_diff:
				max_diff = lst[i] - lst[i - 1]
		print(max(lst[0], max_diff))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	m = 0
	for i in range(1, n):
		m += l[i - 1]
		l[i] -= m
	print(max(l))


import heapq
for step in range(int(input())):
	n = int(input())
	heap = list(map(int, input().split()))
	heapq.heapify(heap)
	ans = -1000000000.0 - 1
	res = 0
	for i in range(n):
		m = heapq.heappop(heap)
		ans = max(m - res, ans)
		res = m
	print(ans)


import heapq
t = int(input())
for case in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	heapq.heapify(l)
	best = heapq.heappop(l)
	subtract = best
	while l:
		x = heapq.heappop(l)
		best = max(best, x - subtract)
		subtract = subtract + (x - subtract)
	print(best)


import sys
import bisect
from bisect import bisect_left as lb
from bisect import bisect_right as rb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs2(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
a = []
(n, k) = (0, 0)
b = []
vis = []
tot = 0
time = []
time1 = []
adj = []
mx = -1
eps = 1e-07
x = 0
pref = []
lvl = []

def update_it(bit, i, val):
	n = len(bit)
	while i < n:
		bit[i] += val
		i += i & -i

def get_ans(bit, i):
	n = len(bit)
	tot = 0
	while i > 0:
		tot += bit[i]
		i -= i & -i
	return tot
prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]

def hnbhai(tc):
	n = sb()
	a = sd()
	a.sort()
	temp = 0
	mx = float('-inf')
	for i in range(n):
		mx = max(mx, a[i] - temp)
		temp += a[i] - temp
	print(mx)
for _ in range(sb()):
	hnbhai(_ + 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())
	m = []
	m.append(A[0])
	prev = A[0]
	for i in range(1, n):
		diff = A[i] - prev
		prev += diff
		m.append(diff)
	print(max(m))


for _ in range(int(input())):
	n = int(input())
	line = [int(i) for i in input().split()]
	line.sort()
	awn = line[0]
	for i in range(n - 1):
		i = line[i + 1] - line[i]
		if i > awn:
			awn = i
	print(awn)


import sys
import math
from collections import defaultdict, Counter, deque
from heapq import heapify, heappop, heappush

class Solution:

	def __init__(self, n, a):
		a.sort()
		self.ans = diff = a[0]
		for i in range(1, n):
			a[i] -= diff
			diff += a[i]
			self.ans = max(self.ans, a[i])

	def exec(self):
		print(self.ans)
test_cases = int(input())
for t in range(1, test_cases + 1):
	n = int(input())
	a = list(map(int, input().split()))
	Solution(n, a).exec()


t = int(input())
result = []
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	b = [a[0]]
	for j in range(n - 1):
		b.append(a[j + 1] - a[j])
	result.append(max(b))
print(*result, sep='\n')


def solve(a):
	a = sorted(a)
	reduction = 0
	minimas = []
	for ai in a:
		new_ai = ai - reduction
		minimas.append(new_ai)
		reduction += new_ai
	return max(minimas)
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	print(solve(a))


testcase = int(input())
for test in range(testcase):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	res = a[0]
	for i in range(1, n):
		res = max(res, a[i] - a[i - 1])
	print(res)


import sys
from os import path
if path.exists('input.txt'):
	sys.stdout = open('output.txt', 'w')
	sys.stdin = open('input.txt', 'r')

def main():
	inp = [int(x) for x in sys.stdin.buffer.read().split()]
	ii = 0
	out = []
	t = int(inp[ii])
	ii += 1
	for _ in range(t):
		n = int(inp[ii])
		ii += 1
		arr = list(map(int, inp[ii:ii + n]))
		ii += n
		arr.sort()
		ans = arr[0]
		for i in range(n):
			if i == 0:
				continue
			ans = max(ans, arr[i] - arr[i - 1])
		out.append(ans)
		pass
	out_str = '\n'.join((str(x) for x in out))
	sys.stdout.write(out_str)
main()


t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = -float('inf')
	count = 0
	for i in range(n):
		a[i] -= count
		ans = max(ans, a[i])
		count += a[i]
	print(ans)


for _ in range(int(input())):
	l = int(input())
	a = input().split()
	for i in range(len(a)):
		a[i] = int(a[i])
	if len(a) == 1:
		print(a[0])
		continue
	a.sort()
	m = a[0]
	for i in range(len(a) - 1):
		m = max(m, a[i + 1] - a[i])
	print(m)


k2 = []
for i in range(int(input())):
	n = int(input())
	a = [int(j) for j in input().split()]
	a1 = sorted(a)
	a1.reverse()
	k1 = []
	if len(a1) == 1:
		k2.append(max(a1))
	else:
		for k in range(n - 1):
			k1.append(a1[k] - a1[k + 1])
		if max(k1) >= min(a1):
			k2.append(max(k1))
		else:
			k2.append(min(a1))
for t1 in k2:
	print(t1)


def find_min(arr, n):
	if n == 1:
		return arr[0]
	arr.sort()
	mins = [arr[0]]
	for i in range(1, n):
		mins.append(arr[i] - arr[i - 1])
	return max(mins)
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	print(find_min(arr, n))


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 1:
		print(arr[0])
		continue
	arr.sort()
	cd = arr[0]
	maxmin = arr[0]
	for i in range(1, n):
		num = arr[i] - cd
		if num > maxmin:
			maxmin = num
		cd += num
	print(maxmin)


n = int(input())
for _ in range(0, n):
	input()
	line = [int(i) for i in input().split()]
	line.sort()
	res = line[0]
	for i in range(0, len(line) - 1):
		diff = line[i + 1] - line[i]
		res = max(res, diff)
	print(res)


import sys
import math
from bisect import bisect_left as bl
from bisect import bisect_right as br
from math import inf
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	mx = arr[0]
	for i in range(n - 1):
		mx = max(mx, arr[i + 1] - arr[i])
	print(mx)


def minmax(n, hello):
	inthello = []
	for i in hello:
		inthello.append(int(i))
	if n == 1:
		return inthello[0]
	inthello.sort()
	sorted = inthello
	maxdif = sorted[0]
	for j in range(n - 1):
		if sorted[j + 1] - sorted[j] > maxdif:
			maxdif = sorted[j + 1] - sorted[j]
	return maxdif
total = int(input())
for i in range(total):
	n = int(input())
	hello = input().split()
	print(minmax(n, hello))


num_inp = lambda : int(input())
arr_inp = lambda : list(map(int, input().split()))
sp_inp = lambda : map(int, input().split())
str_inp = lambda : input()
for s in [*open(0)][2::2]:
	a = sorted(map(int, s.split()))
	print(max((y - x for (x, y) in zip([0] + a, a))))


import sys

def rall():
	return sys.stdin.readlines()

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

def rl_types(types):
	str_list = [x for x in sys.stdin.readline().strip().split(' ')]
	return [types[i](str_list[i]) for i in range(len(str_list))]

def pr(something=''):
	sys.stdout.write(str(something) + '\n')

def pra(array):
	sys.stdout.write(' '.join([str(x) for x in array]) + '\n')

def solve(array):
	return array
NT = int(rl())
for ti in range(NT):
	_ = int(rl())
	array = list(map(int, rl().split(' ')))
	if True:
		s = sorted(array)
		l = s[0]
		mx = s[0]
		for v in s[1:]:
			d = v - l
			mx = max(mx, d)
			l = v
	pr(mx)


import sys
inp = sys.stdin
count = int(inp.readline())
arr_length = []
lines = []
for i in range(count):
	arr_length.append(int(inp.readline()))
	lines.append(inp.readline().split())
inp.close()
outp = sys.stdout
for j in range(count):
	line = lines[j]
	(al, arr) = (arr_length[j], lines[j])
	arr = [int(el) for el in arr]
	arr.sort()
	cur_add = 0
	max_i = 0
	max_val = arr[0]
	if al > 1:
		for i in range(al - 1):
			cur_range = -arr[i]
			cur_add += cur_range
			if arr[i + 1] + cur_range > max_val:
				max_val = arr[i + 1] + cur_range
				max_i += 1
	outp.write(str(max_val))
	if j != count - 1:
		outp.write('\n')
outp.close()


test = int(input())
for _ in range(test):
	n = int(input())
	arr = [int(x) for x in input().split()]
	arr.sort()
	ans = arr[0]
	diff = arr[0]
	for i in range(1, n):
		ele = arr[i] - diff
		ans = max(ans, ele)
		diff += ele
	print(ans)


from __future__ import division, print_function
import os, 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

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

def fi():
	return float(input())

def si():
	return input()

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

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

def li():
	return list(mi())

def lsi():
	return list(msi())

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

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // gcd(x, y)
mod = 1000000007

def modInverse(b, m):
	g = gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def ceil2(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def modu(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -999999999
	else:
		return inv * a % m
from math import log, factorial, cos, tan, sin, radians, floor, sqrt, ceil, log2
import bisect
import random
import string
from decimal import *
getcontext().prec = 50
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def gcd1(a):
	if len(a) == 1:
		return a[0]
	ans = a[0]
	for i in range(1, len(a)):
		ans = gcd(ans, a[i])
	return ans

def mykey(x):
	return len(x)

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		a.sort()
		ans = -10000000000.0
		s = 0
		for i in range(n):
			ans = max(ans, a[i] - s)
			s = a[i]
		print(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')

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')
main()


t = int(input())
result = []
for i in range(t):
	n = int(input())
	a = sorted(list(map(int, input().strip().split())))
	if n > 1:
		b = [a[0]]
		for j in range(n - 1):
			b.append(a[j + 1] - a[j])
		result.append(max(b))
	elif n == 1:
		result.append(a[0])
for i in result:
	print(i)


T = int(input())
while T > 0:
	T -= 1
	n = int(input())
	array = sorted([int(x) for x in input().split()])
	ans = array[0]
	for i in range(len(array) - 1):
		ans = max(ans, array[i + 1] - array[i])
	print(ans)


t = int(input())
for t in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	ans = a[0]
	for i in range(1, n):
		if a[i] - a[i - 1] > ans:
			ans = a[i] - a[i - 1]
	print(ans)


for _ in range(int(input())):
	(_, a) = (input(), sorted(map(int, input().split())))
	print(max(a[0], max((n - p for (p, n) in zip(a, a[1:])))) if len(a) > 1 else a[0])


def readint():
	return int(input())

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

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

def main():
	t = readint()
	for _ in range(t):
		n = readint()
		a = readarr()
		a.sort()
		maximal = a[0]
		for i in range(1, n):
			maximal = max(maximal, a[i] - a[i - 1])
		print(maximal)
main()


import math
from collections import Counter
import copy
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	prev = arr[0]
	ans = prev
	for i in range(1, n):
		temp = arr[i] - prev
		ans = max(ans, temp)
		prev += temp
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	if n == 1:
		a = int(input())
		print(a)
	else:
		li = [int(x) for x in input().split()]
		li.sort()
		v = []
		v.append(li[0])
		for i in range(1, n):
			v.append(li[i] - li[i - 1])
		print(max(v))


t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min = a[0]
	minus = a[0]
	for index in range(1, n):
		a[index] -= minus
		if min < a[index]:
			min = a[index]
		minus += a[index]
	print(min)
	t -= 1


from bisect import insort, bisect_right, bisect_left
from sys import stdout, stdin, setrecursionlimit
from heapq import heappush, heappop, heapify
from io import BytesIO, IOBase
from collections import *
from itertools import *
from random import *
from string import *
from queue import *
from math import *
from re import *
from os import *
from operator import truediv

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 = read(self._fd, max(fstat(self._fd).st_size, 8192))
			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 = read(self._fd, max(fstat(self._fd).st_size, 8192))
			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:
			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(stdin), IOWrapper(stdout))
(graph, mod, szzz) = ({}, 10 ** 9 + 7, lambda : sorted(zzz()))

def getStr():
	return input()

def getInt():
	return int(input())

def listStr():
	return list(input())

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

def isInt(s):
	return '0' <= s[0] <= '9'

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

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

def output(answer, end='\n'):
	stdout.write(str(answer) + end)

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def getPrimes(N=10 ** 5):
	SN = int(sqrt(N))
	sieve = [i for i in range(N + 1)]
	sieve[1] = 0
	for i in sieve:
		if i > SN:
			break
		if i == 0:
			continue
		for j in range(2 * i, N + 1, i):
			sieve[j] = 0
	prime = [i for i in range(N + 1) if sieve[i] != 0]
	return prime

def primeFactor(n, prime=getPrimes()):
	lst = []
	mx = int(sqrt(n)) + 1
	for i in prime:
		if i > mx:
			break
		while n % i == 0:
			lst.append(i)
			n //= i
	if n > 1:
		lst.append(n)
	return lst
dx = [-1, 1, 0, 0, 1, -1, 1, -1]
dy = [0, 0, 1, -1, 1, -1, -1, 1]
daysInMounth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
num = getInt()
for _ in range(num):
	n = getInt()
	arr = szzz()
	res = arr[0]
	curr = arr[0]
	for i in range(1, n):
		arr[i] -= curr
		res = max(res, arr[i])
		curr += arr[i]
	print(res)


import sys, collections, math, bisect, heapq, random, functools
input = sys.stdin.readline
out = sys.stdout.flush

def solve():
	n = int(input())
	k = [*map(int, input().split())]
	k.sort()
	ans = k[0]
	diff = -k[0]
	for i in range(1, n):
		cur = k[i] + diff
		ans = max(cur, ans)
		diff -= cur
	print(ans)
for i in range(int(input())):
	solve()


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
inp_vars_int = lambda : map(int, input().split())
inp_list_int = lambda : list(map(int, input().split()))
t = int(input())
for _ in range(t):
	_ = input()
	a = inp_list_int()
	n = len(a)
	a_s = sorted(a)
	diff = [a_s[i] - a_s[i - 1] for i in range(1, n)]
	d_s = sorted(diff)
	if n == 1:
		print(a[0])
	else:
		print(max(a_s[0], max(d_s)))


import math
from heapq import heappush, heappop, heapify
import random
import string
from collections import deque
from bisect import bisect, bisect_left, bisect_right, insort
import sys
input = sys.stdin.readline
S = lambda : input().rstrip()
I = lambda : int(S())
M = lambda : map(int, S().split())
L = lambda : list(M())
H = 1000000000 + 7
for _ in range(I()):
	n = I()
	l = L()
	if len(l) == 1:
		print(l[0])
		continue
	p = min(l)
	if p < 0:
		l.pop(l.index(p))
		for i in range(n - 1):
			l[i] -= p
	l.sort()
	m = min(l)
	for i in range(len(l) - 1):
		m = max(l[i + 1] - l[i], m)
	print(m)


from __future__ import print_function
from math import *
from collections import deque
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
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')
mod = 10 ** 9 + 7

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

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

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	n = inp()
	l = inlt()
	l.sort()
	ans = l[0]
	tmp = 0
	for i in range(n - 1):
		tmp += l[i] - tmp
		ans = max(ans, l[i + 1] - tmp)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = sorted(list(map(int, input().split()))[:n])
	m = d = s[0]
	for i in range(1, n):
		s[i] -= d
		d += s[i]
		m = max(m, s[i])
	print(m)


from math import ceil, log2, floor, sqrt, gcd
from collections import defaultdict, deque
import sys
import os.path
sys.setrecursionlimit(200000)
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r+')
	sys.stdout = open('output.txt', 'w')

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

def bfs(s, adj):
	V = 10 ** 5 + 2
	visited = [False] * V
	level = [0] * V
	for i in range(V):
		visited[i] = False
		level[i] = 0
	queue = deque()
	visited[s] = True
	queue.append(s)
	level[s] = 0
	while len(queue) > 0:
		s = queue.popleft()
		for i in adj[s]:
			if not visited[i]:
				level[i] = level[s] + 1
				visited[i] = True
				queue.append(i)
	return level

def dfs(node, tree, d, v):
	v[node] = 1
	for j in d[node]:
		if v[j] == 0:
			tree[node].append(j)
			dfs(j, tree, d, v)
mod = 10 ** 9 + 7

def solve(testcase):
	n = int(input())
	a = list(MI())
	a.sort()
	neg = pos = 0
	m = 10 ** 10
	minp = 10 ** 10
	ans = min(a)
	m1 = -10 ** 10
	maxp = -10 ** 10
	for i in a:
		ans = max(ans, i - neg)
		if i - neg > 0:
			pos += i - neg
			neg += i - neg
		else:
			neg += i - neg
	print(ans)
t = int(input())
for _ in range(t):
	solve(_ + 1)


t = int(input())
nth = []
arr = []
for i in range(t):
	nth.append(int(input()))
	inp = input().split(' ')
	arr.append([])
	for j in range(nth[i]):
		arr[i].append(int(inp[j]))
	arr[i].sort()
for i in range(t):
	min = arr[i][0]
	if nth[i] == 1:
		print(min)
		continue
	else:
		for j in range(1, nth[i]):
			if arr[i][j] - arr[i][j - 1] > min:
				min = arr[i][j] - arr[i][j - 1]
	print(min)


for _ in range(int(input())):
	n = int(input())
	line = sorted(list(map(int, input().split())))
	k = line[0]
	for i in range(1, n):
		k = max(k, line[i] - line[i - 1])
	print(k)


n = int(input())
for i in range(n):
	x = int(input())
	lis = list(map(int, input().split()))
	if x == 1:
		print(*lis)
	else:
		lis.sort()
		fi = lis[0]
		check = lis[0]
		for i in lis[1:]:
			fi = max(fi, i - check)
			check = i
		print(fi)


for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	b.sort()
	max = b[0]
	for i in range(a - 1):
		if b[i + 1] - b[i] > max:
			max = b[i + 1] - b[i]
	print(max)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	maxes = []
	m = 0
	while len(arr) != 1:
		maxes.append(arr[-1] - m)
		m += arr[-1] - m
		del arr[-1]
	maxes.append(arr[0] - m)
	print(max(maxes))


import heapq
n = int(input())
arr = []
for i in range(n):
	t = int(input())
	tmp = input().split()
	tmp = list(map(int, tmp))
	tmp.sort()
	tmp2 = [tmp[0]]
	tmp3 = [tmp[i] - tmp[i - 1] for i in range(1, len(tmp))]
	tmp2.extend(tmp3)
	ans = max(tmp2)
	print(ans)


import sys

def input():
	return sys.stdin.readline().rstrip()
t = int(input())
for _ in range(t):
	n = int(input())
	lst = sorted(list(map(int, input().split())))
	tmp = lst[0]
	for i in range(n - 1):
		tmp = max(tmp, lst[i + 1] - lst[i])
	print(tmp)


import sys
import heapq

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

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

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

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

def get_list_strings():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve(n, arr):
	ans = min(arr)
	c = 0
	heapq.heapify(arr)
	while n > 1:
		temp = heapq.heappop(arr)
		n -= 1
		temp1 = temp - c
		ans = max(ans, temp1)
		c += temp1
	temp = heapq.heappop(arr)
	temp1 = temp - c
	ans = max(ans, temp1)
	print(ans)
T = get_int()
while T:
	n = get_int()
	arr = get_list()
	solve(n, arr)
	T -= 1


import math

def solve():
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	temp = []
	temp.append(a[0])
	for i in range(1, len(a)):
		temp.append(a[i] - a[i - 1])
	return max(temp)
n = int(input())
for i in range(n):
	print(solve())


def si():
	return str(input())

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

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

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

def li():
	return list(mi())

def main():
	for _ in range(ii()):
		n = ii()
		a = li()
		a.sort()
		for i in range(len(a) - 1, 0, -1):
			a[i] = a[i] - a[i - 1]
		print(max(a))
main()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if n == 1:
		print(a[0])
	elif n == 2:
		print(max(min(a), max(a) - min(a)))
	else:
		a.sort()
		a1 = []
		a1.append(a[0])
		s = -float('inf')
		for i in range(len(a) - 1):
			a1.append(a[i + 1] - a[i])
		print(max(a1))


for tc in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 1:
		print(l[0])
		continue
	l.sort()
	maxi = l[0]
	for i in range(1, n):
		maxi = max(l[i] - l[i - 1], maxi)
	print(maxi)


for t in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	if len(lis) == 1:
		print(lis[0])
	else:
		lis.sort()
		maximum = lis[-1]
		count = 0
		index = -1
		if lis[0] < 0:
			temp = lis[0]
			for i in range(len(lis)):
				lis[i] = lis[i] - temp
		for i in range(len(lis)):
			if lis[i] == 0:
				index = i
		if index == n - 1:
			print(0)
		else:
			lis = lis[index + 1:]
			if len(lis) == 1:
				print(lis[0])
			else:
				count = 0
				res = lis[0]
				for i in range(len(lis)):
					val = lis[i] - count
					if val > res:
						res = val
					count += val
				print(res)


from sys import stdin, stdout
input = stdin.readline

def ceil(a, b):
	return (a + b - 1) // b
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a = sorted(a)
	ans = a[0]
	delta = 0
	for i in range(n - 1):
		delta -= a[i] + delta
		ans = max(ans, a[i + 1] + delta)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	if n == 1:
		print(a[0])
	else:
		mini = min(a)
		for i in range(n - 1):
			if a[i + 1] - a[i] > mini:
				mini = a[i + 1] - a[i]
		print(mini)


import math
from collections import OrderedDict
t = int(input())
while t > 0:
	n = int(input())
	inp = input()
	a = list(map(int, inp.split(' ')))
	flag = 1
	a.sort()
	if n == 1:
		print(a[0])
	else:
		max = a[0]
		for i in range(0, n - 1):
			s = a[i + 1] - a[i]
			if s > max:
				max = s
		print(max)
	t -= 1


def solve(n, a):
	if n == 1:
		print(a[0])
	else:
		a = sorted(a, reverse=True)
		diff = [a[i] - a[i + 1] for i in range(len(a) - 1)]
		ans = max(max(diff), a[-1])
		print(ans)
debugmode = 0
if debugmode:
	with open('input.txt', 'r') as f:
		t = int(f.readline())
		for _ in range(t):
			n = int(f.readline())
			a = list(map(int, f.readline().split()))
			solve(n, a)
else:
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		solve(n, a)


def calc(a, n):
	if n % 2 == 0:
		for i in range(n):
			if i % 2 == 0:
				a[-1] -= a[i]
	else:
		for i in range(n):
			if i % 2 == 1:
				a[-1] -= a[i]
	return a[-1]

def op():
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	o = a[0]
	for i in range(n - 1):
		if a[i + 1] - a[i] > o:
			o = a[i + 1] - a[i]
	return o
o = []
for i in range(int(input())):
	print(op())


import sys
t = int(input())
res = []
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a = sorted(a)
	x = -sys.maxsize - 1
	s = 0
	for i in range(n):
		x = max(x, a[i])
		s += a[i]
		if i < n - 1:
			a[i + 1] -= s
	res.append(x)
for index in range(t):
	print(res[index])


import sys
from heapq import heappush, heappop
input = sys.stdin.readline
t = int(input())
_ans = []
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	heap = []
	ans = -10000000000.0 - 1
	if a[0] < 0:
		ans = max(ans, a[0])
		for i in range(1, n):
			heappush(heap, a[i] - a[0])
	else:
		for i in range(n):
			heappush(heap, a[i])
	p = 0
	while len(heap) > 0:
		v = heappop(heap)
		ans = max(ans, v - p)
		p += v - p
	_ans.append(ans)
for el in _ans:
	print(el)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if len(arr) == 1:
		print(arr[0])
		continue
	arr.sort()
	sumo = arr[0]
	res = arr[0]
	for i in range(1, len(arr)):
		if i == len(arr):
			break
		box = arr[i] - sumo
		sumo = sumo + box
		if box > res:
			res = box
	print(res)


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	res = arr[0]
	for i in range(n - 1):
		res = max(res, arr[i + 1] - arr[i])
	return res
t = int(input())
while t:
	print(solve())
	t -= 1


import math
import os
import sys
from io import BytesIO, IOBase
M = 1000000007
import random
import heapq
import threading
import bisect
import time
from functools import *
from collections import *
from itertools import *
BUFSIZE = 8192
import array

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')

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

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

def stringlis():
	return list(map(str, inp().split()))

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

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def inpu():
	return int(inp())

def build(arr, a, b, st, node):
	if a == b:
		st[node] = arr[a]
		return st[node]
	mid = (a + b) // 2
	st[node] = min(build(arr, a, mid, st, 2 * node + 1), build(arr, mid + 1, b, st, 2 * node + 2))
	return st[node]

def getmin(arr, a, b, l, r, st, node):
	if l > b or r < a:
		return float('inf')
	if l <= a and r >= b:
		return st[node]
	mid = (a + b) // 2
	return min(getmin(arr, a, mid, l, r, st, 2 * node + 1), getmin(arr, mid + 1, b, l, r, st, 2 * node + 2))

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		n = inpu()
		arr = lis()
		arr.sort()
		ans = arr[0]
		for i in range(1, n):
			ans = max(ans, arr[i] - arr[i - 1])
		print(ans)
main()


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	m = -10 ** 9 - 1
	for i in range(len(arr) - 1):
		x = arr[i + 1] - arr[i]
		m = max(m, x)
	if len(arr) > 1:
		print(max(arr[0], m))
	else:
		print(arr[0])


def solve():
	n = int(input())
	a = sorted([int(x) for x in input().split()])
	max_min = a[0]
	sub = max_min
	for i in range(1, n):
		a[i] -= sub
		sub += a[i]
		max_min = max(max_min, a[i])
	return max_min
t = int(input())
for _ in range(t):
	print(solve())


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


from sys import stdin as f
from heapq import heapify, heappush, heappop
t = int(next(f))
out = []
for _ in range(t):
	n = int(next(f))
	a = list(map(int, input().split()))
	heapify(a)
	c = 0
	mx = -float('inf')
	m = heappop(a)
	while len(a) > 0:
		if m > mx:
			mx = m
		c += m
		m = heappop(a) - c
	if m > mx:
		mx = m
	out.append(mx)
print(*out, sep='\n')


import os
import sys
from io import BytesIO, IOBase
_str = str
str = lambda x=b'': x if type(x) is bytes else _str(x).encode()
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')
testcases = int(input())
for tc in range(testcases):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = a[0]
	buffer = 0
	for i in range(n):
		ans = max(ans, a[i] + buffer)
		buffer += -(a[i] + buffer)
	print(ans)


from collections import deque
t = int(input())
for _ in range(t):
	ln = int(input())
	arr = deque(sorted(list(map(int, input().split()))))
	ans = -1000000000
	stk = 0
	for _ in range(len(arr)):
		mi = arr.popleft()
		if ans < mi - stk:
			ans = mi - stk
		stk += mi - stk
	print(ans)


def solve():
	n = int(input())
	a = sorted(map(int, input().split()))
	ans = a[0]
	for (v, nv) in zip(a, a[1:]):
		ans = max(ans, nv - v)
	print(ans)
for _ in range(int(input())):
	solve()


import sys, math

def solve():
	n = int(input())
	l = list(map(int, input().split()))
	if len(l) == 1:
		print(l[0])
		return
	l.sort()
	ans = []
	ans.append(l[0])
	for i in range(len(l)):
		if i == 0:
			dec = l[0]
			continue
		val = l[i] - dec
		ans.append(val)
		dec += val
	print(max(ans))
t = int(input())
while t != 0:
	solve()
	t -= 1


from heapq import heapify, heappop
from sys import stdin

def maximize(l):
	heapify(l)
	total = 0
	result = None
	while len(l) != 0:
		s = heappop(l)
		d = s - total
		total = s
		if result is None:
			result = d
		else:
			result = max(result, d)
	return result
t = int(stdin.readline())
for _ in range(t):
	stdin.readline()
	data = [int(d) for d in stdin.readline().strip().split()]
	result = maximize(data)
	print(result)


def f():
	n = int(input())
	l = sorted(map(int, input().split()))
	if n == 1:
		return l[0]
	t = l[0]
	for i in range(1, n):
		t = max(t, l[i] - l[i - 1])
	return t
for _ in range(int(input())):
	print(f())