Dark is going to attend Motarack's birthday. Dark decided that the gift he is going to give to Motarack is an array $a$ of $n$ non-negative integers.

Dark created that array $1000$ years ago, so some elements in that array disappeared. Dark knows that Motarack hates to see an array that has two adjacent elements with a high absolute difference between them. He doesn't have much time so he wants to choose an integer $k$ ($0 \leq k \leq 10^{9}$) and replaces all missing elements in the array $a$ with $k$.

Let $m$ be the maximum absolute difference between all adjacent elements (i.e. the maximum value of $|a_i - a_{i+1}|$ for all $1 \leq i \leq n - 1$) in the array $a$ after Dark replaces all missing elements with $k$.

Dark should choose an integer $k$ so that $m$ is minimized. Can you help him?


-----Input-----

The input consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$)  — the number of test cases. The description of the test cases follows.

The first line of each test case contains one integer $n$ ($2 \leq n \leq 10^{5}$) — the size of the array $a$.

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ($-1 \leq a_i \leq 10 ^ {9}$). If $a_i = -1$, then the $i$-th integer is missing. It is guaranteed that at least one integer is missing in every test case.

It is guaranteed, that the sum of $n$ for all test cases does not exceed $4 \cdot 10 ^ {5}$.


-----Output-----

Print the answers for each test case in the following format:

You should print two integers, the minimum possible value of $m$ and an integer $k$ ($0 \leq k \leq 10^{9}$) that makes the maximum absolute difference between adjacent elements in the array $a$ equal to $m$.

Make sure that after replacing all the missing elements with $k$, the maximum absolute difference between adjacent elements becomes $m$.

If there is more than one possible $k$, you can print any of them.


-----Example-----
Input
7
5
-1 10 -1 12 -1
5
-1 40 35 -1 35
6
-1 -1 9 -1 3 -1
2
-1 -1
2
0 -1
4
1 -1 3 -1
7
1 -1 7 5 2 -1 5

Output
1 11
5 35
3 6
0 42
0 0
1 2
3 4



-----Note-----

In the first test case after replacing all missing elements with $11$ the array becomes $[11, 10, 11, 12, 11]$. The absolute difference between any adjacent elements is $1$. It is impossible to choose a value of $k$, such that the absolute difference between any adjacent element will be $\leq 0$. So, the answer is $1$.

In the third test case after replacing all missing elements with $6$ the array becomes $[6, 6, 9, 6, 3, 6]$.  $|a_1 - a_2| = |6 - 6| = 0$;  $|a_2 - a_3| = |6 - 9| = 3$;  $|a_3 - a_4| = |9 - 6| = 3$;  $|a_4 - a_5| = |6 - 3| = 3$;  $|a_5 - a_6| = |3 - 6| = 3$. 

So, the maximum difference between any adjacent elements is $3$.

Difficulty: MEDIUM

Solutions:
def solve(A, N):
	adj = set()
	m = 0
	for i in range(N - 1):
		if A[i] != -1 and A[i + 1] != -1:
			m = max(m, abs(A[i + 1] - A[i]))
		if A[i] == -1 and A[i + 1] != -1:
			adj.add(A[i + 1])
		if A[i] != -1 and A[i + 1] == -1:
			adj.add(A[i])
	if not adj:
		return '0 0'
	maxVal = max(adj)
	minVal = min(adj)
	k = (maxVal + minVal) // 2
	m = max(m, abs(maxVal - k), abs(minVal - k))
	return str(m) + ' ' + str(k)
(T,) = map(int, input().split())
for t in range(T):
	(N,) = map(int, input().split())
	A = [int(x) for x in input().split()]
	ans = solve(A, N)
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	st = []
	mx = 0
	for i in range(n):
		if a[i] == -1:
			if i + 1 < n and a[i + 1] != -1:
				st.append(a[i + 1])
			if i - 1 >= 0 and a[i - 1] != -1:
				st.append(a[i - 1])
		if i > 0 and a[i] != -1 and (a[i - 1] != -1) and (abs(a[i] - a[i - 1]) > mx):
			mx = abs(a[i] - a[i - 1])
	st.sort()
	if len(st):
		mx1 = (st[0] + st[-1]) // 2
	else:
		mx1 = 0
	if len(st):
		mx = max(mx, mx1 - st[0], st[-1] - mx1)
	print(mx, mx1)


import sys
input = sys.stdin.readline
t = int(input())
for ii in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	p = []
	for i in range(n):
		if i == 0:
			if l[i] != -1 and l[i + 1] == -1:
				p.append(l[i])
		elif i == n - 1:
			if l[i] != -1 and l[i - 1] == -1:
				p.append(l[i])
		elif l[i] != -1 and (l[i - 1] == -1 or l[i + 1] == -1):
			p.append(l[i])
	if len(p) == 0:
		z = 0
	else:
		z = (max(p) + min(p)) // 2
	a = 0
	for i in range(n):
		if l[i] == -1:
			l[i] = z
	for i in range(n - 1):
		a = max(a, abs(l[i] - l[i + 1]))
	print(a, z)


from math import ceil, floor
t = int(input())
import bisect
while t:
	n = int(input())
	l = list(map(int, input().split()))
	ll = set()
	ans = 0
	for i in range(n):
		if l[i] == -1:
			if i + 1 < n and l[i + 1] != -1:
				ll.add(l[i + 1])
			if i - 1 >= 0 and l[i - 1] != -1:
				ll.add(l[i - 1])
		else:
			if i + 1 < n and l[i + 1] != -1:
				ans = max(ans, abs(l[i] - l[i + 1]))
			if i - 1 >= 0 and l[i - 1] != -1:
				ans = max(ans, abs(l[i] - l[i - 1]))
	ll = list(ll)
	ll.sort()
	n = len(ll)
	if n:
		su = min(ll) + max(ll)
		ans1 = ans
		ans2 = ans
		su1 = ceil(su / 2)
		su2 = floor(su / 2)
		for i in ll:
			ans1 = max(ans1, abs(i - su1))
			ans2 = max(ans2, abs(i - su2))
		if ans1 < ans2:
			print(ans1, su1)
		else:
			print(ans2, su2)
	else:
		print(0, 0)
	t -= 1


import sys
from pprint import pprint
if not 'DEBUG' in globals():
	readline = sys.stdin.readline

def read(map_func):
	return map_func(readline().rstrip())

def reads(map_func):
	return list(map(map_func, readline().rstrip().split()))

def readn(map_func, n):
	return [map_func(readline().rstrip()) for _ in range(n)]

def readint():
	return read(int)

def readints():
	return reads(int)

def readcol(n):
	return readn(int)

def readmat(n):
	return [readints() for _ in range(n)]

def readmap(n):
	return readn(list)

def makemat(n, m, v):
	return [[v for _ in range(m)] for _ in range(n)]

def zeromat(n, m=None):
	return makemat(n, m if m else n, 0)

def listmat(n, m=None):
	return [[[] for _ in range(m if m else n)] for _ in range(n)]

def crosslist(y, x, n=None, m=None):
	return [(p, q) for (p, q) in [(y, x + 1), (y - 1, x), (y, x - 1), (y + 1, x)] if (n == None or 0 <= p < n) and (m == None or 0 <= q < m)]

def roundlist(y, x, n=None, m=None):
	return [(p, q) for (p, q) in [(y, x + 1), (y - 1, x + 1), (y - 1, x), (y - 1, x - 1), (y, x - 1), (y + 1, x - 1), (y + 1, x), (y + 1, x + 1)] if (n == None or 0 <= p < n) and (m == None or 0 <= q < m)]

def plog(obj):
	pprint(obj) if 'DEBUG' in globals() else None

def log(msg, label=None):
	print((label + ': ' if label else '') + str(msg)) if 'DEBUG' in globals() else None

def _logmat(mat, label=None):
	fmt = '{:' + str(max((max((len(str(s)) for s in m)) for m in mat))) + 'd}'
	f = lambda row: '[' + ' '.join((fmt.format(x) for x in row)) + ']'
	[log('[' + f(row), label) if i == 0 else log((' ' * (len(label) + 3) if label else ' ') + f(row) + ']', None) if i == len(mat) - 1 else log((' ' * (len(label) + 3) if label else ' ') + f(row), None) for (i, row) in enumerate(mat)]

def logmat(mat, label=None):
	_logmat(mat, label) if 'DEBUG' in globals() else None

def solve(A, N):
	B = []
	for i in range(N):
		if A[i] != -1:
			if i == 0:
				if A[i + 1] == -1:
					B.append(A[i])
			elif i == N - 1:
				if A[i - 1] == -1:
					B.append(A[i])
			elif A[i - 1] == -1 or A[i + 1] == -1:
				B.append(A[i])
	if not B:
		return (0, 0)
	p = max(B)
	q = min(B)
	k = (p + q) // 2
	C = [k if b == -1 else b for b in A]
	m = 0
	for i in range(1, N):
		m = max(abs(C[i] - C[i - 1]), m)
	return (m, k)
for _ in range(readint()):
	N = readint()
	A = readints()
	(m, k) = solve(A, N)
	print(m, k)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for j in range(n):
		if a[j] == -1:
			if j != n - 1 and a[j + 1] != -1:
				b.append(a[j + 1])
			if j != 0 and a[j - 1] != -1:
				b.append(a[j - 1])
	b.sort()
	if len(b) == 0:
		ans = 0
	elif len(b) == 1:
		ans = b[0]
	else:
		ans = (b[0] + b[-1]) // 2
	m = 0
	for j in range(1, n):
		if a[j - 1] == -1:
			a[j - 1] = ans
		if a[j] == -1:
			a[j] = ans
		m = max(m, abs(a[j] - a[j - 1]))
	print(m, ans)


for ttt in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	minus_one = arr.count(-1)
	if n == minus_one:
		print(0, 0)
		continue
	res = []
	for i in range(n):
		if arr[i] == -1:
			if i == 0:
				if arr[i + 1] != -1:
					res.append(arr[i + 1])
			elif i == n - 1:
				if arr[i - 1] != -1:
					res.append(arr[i - 1])
			else:
				if arr[i - 1] != -1:
					res.append(arr[i - 1])
				if arr[i + 1] != -1:
					res.append(arr[i + 1])
	maxi = max(res)
	mini = min(res)
	mm = (mini + maxi) // 2
	for i in range(n):
		if arr[i] == -1:
			arr[i] = mm
	maxiiii = 0
	for i in range(n - 1):
		maxiiii = max(maxiiii, abs(arr[i] - arr[i + 1]))
	print(maxiiii, mm)


import math
t = int(input())
for i in range(t):
	kMax = -1000000000
	kMin = 1000000000
	n = int(input())
	array = input()
	array = array.split(' ')
	array = [int(x) for x in array]
	for i in range(len(array)):
		if i > 0 and array[i] == -1 and (array[i - 1] != -1):
			kMax = max([kMax, array[i - 1]])
			kMin = min([kMin, array[i - 1]])
		if i < n - 1 and array[i] == -1 and (array[i + 1] != -1):
			kMax = max([kMax, array[i + 1]])
			kMin = min([kMin, array[i + 1]])
	k = (kMax + kMin) // 2
	for i in range(len(array)):
		if array[i] == -1:
			array[i] = k
	maxDifference = 0
	for i in range(len(array) - 1):
		maxDifference = max([maxDifference, abs(array[i] - array[i + 1])])
	print(maxDifference, k)


for t in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	temp = []
	if l[0] != -1 and l[1] == -1:
		temp.append(l[0])
	for i in range(1, n - 1):
		if l[i] != -1 and (l[i - 1] == -1 or l[i + 1] == -1):
			temp.append(l[i])
	if l[n - 1] != -1 and l[n - 2] == -1:
		temp.append(l[n - 1])
	if len(temp) == 0:
		print(0, 0)
		continue
	mi = min(temp)
	ma = max(temp)
	no = (ma + mi) // 2
	dif = 0
	for i in range(n - 1):
		if l[i] == -1:
			l[i] = no
		if l[i + 1] == -1:
			l[i + 1] = no
		if abs(l[i] - l[i + 1]) > dif:
			dif = abs(l[i] - l[i + 1])
	print(dif, no)


t = int(input())
for j in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	d_r = []
	d_x = []
	for i in range(1, len(a)):
		if a[i] != -1 and a[i - 1] != -1:
			d_r.append(abs(a[i] - a[i - 1]))
		elif a[i] == -1 and a[i - 1] != -1:
			d_x.append(a[i - 1])
		elif a[i] != -1 and a[i - 1] == -1:
			d_x.append(a[i])
	if len(d_r) == 0:
		Max = 0
	else:
		Max = max(d_r)
	if len(d_x) == 0:
		(xMax, xMin) = (0, 0)
	else:
		(xMax, xMin) = (max(d_x), min(d_x))
	k = (xMin + xMax) // 2
	m = xMax - k if xMax - k > Max else Max
	print(m, k)


import sys
import math

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

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

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

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

def absdefpair(a):
	return max([abs(s - t) for (s, t) in zip(a, a[1:])])
for _ in range(int(input())):
	N = int(input())
	A = alele()
	B = []
	if A[0] != -1 and A[1] == -1:
		B.append(A[0])
	if A[-1] != -1 and A[-2] == -1:
		B.append(A[-1])
	for i in range(1, len(A) - 1):
		if (A[i - 1] == -1 or A[i + 1] == -1) and A[i] != -1:
			B.append(A[i])
	dif3 = 1000000000.0
	value2 = 0
	if B:
		k = (min(B) + max(B)) // 2
		for i in range(k - 1, k + 1):
			B = A.copy()
			diff = -1000000000.0
			if B[0] == -1:
				B[0] = i
			for j in range(1, len(B)):
				if B[j] == -1:
					if B[j - 1] == -1:
						dif = 0
					else:
						dif = abs(B[j - 1] - i)
				elif B[j - 1] == -1:
					dif = abs(B[j] - i)
				else:
					dif = abs(B[j - 1] - B[j])
				if dif >= diff:
					diff = dif
					value = i
			if diff <= dif3:
				dif3 = diff
				value2 = value
		print(dif3, value2)
	else:
		print(0, 0)


for _ in range(int(input())):
	n = int(input())
	mn = 10000000000
	mx = -1
	inp = [int(i) for i in input().split()]
	for i in range(n):
		if inp[i] != -1:
			if i > 0 and inp[i - 1] == -1:
				mn = min(mn, inp[i])
				mx = max(mx, inp[i])
			if i < n - 1 and inp[i + 1] == -1:
				mn = min(mn, inp[i])
				mx = max(mx, inp[i])
	if mx == -1:
		k = 0
	else:
		k = (mx + mn) // 2
	ans = 0
	if inp[0] == -1:
		inp[0] = k
	for i in range(1, n):
		if inp[i] == -1:
			inp[i] = k
		ans = max(ans, abs(inp[i] - inp[i - 1]))
	print(ans, k)


import sys

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	A = LIST()
	mx = 0
	S = set()
	for i in range(N - 1):
		if A[i] != -1 and A[i + 1] != -1:
			mx = max(mx, abs(A[i] - A[i + 1]))
		if A[i] != -1 and A[i + 1] == -1:
			S.add(A[i])
		if A[i] == -1 and A[i + 1] != -1:
			S.add(A[i + 1])
	if S:
		li = sorted(S)
		k = (li[0] + li[-1]) // 2
		m = max(max(li[-1] - k, k - li[0]), mx)
		print(m, k)
	else:
		print(mx, 0)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	temp = []
	minm = 10 ** 9 + 1
	maxm = -10 ** 9 - 1
	for i in range(n):
		if a[i] != -1:
			if i == 0:
				if a[1] == -1:
					temp.append(a[i])
			elif i == n - 1:
				if a[i - 1] == -1:
					temp.append(a[i])
			elif a[i - 1] == -1 or a[i + 1] == -1:
				temp.append(a[i])
	if len(temp) != 0:
		maxm = max(temp)
		minm = min(temp)
	k = (maxm + minm) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	m = -10
	for i in range(1, n):
		m = max(m, abs(a[i] - a[i - 1]))
	print(m, k)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	minAdj = max(a)
	maxAdj = min(a)
	if a[0] == -1:
		if a[1] != -1:
			if a[1] > maxAdj:
				maxAdj = a[1]
			if a[1] < minAdj:
				minAdj = a[1]
	if a[n - 1] == -1:
		if a[n - 2] != -1:
			if a[n - 2] > maxAdj:
				maxAdj = a[n - 2]
			if a[n - 2] < minAdj:
				minAdj = a[n - 2]
	for i in range(1, n - 1):
		if a[i] == -1:
			if a[i - 1] != -1:
				if a[i - 1] > maxAdj:
					maxAdj = a[i - 1]
				if a[i - 1] < minAdj:
					minAdj = a[i - 1]
			if a[i + 1] != -1:
				if a[i + 1] > maxAdj:
					maxAdj = a[i + 1]
				if a[i + 1] < minAdj:
					minAdj = a[i + 1]
	if minAdj == -1 and maxAdj == -1:
		minAdj = 0
		maxAdj = 0
	m = 0
	k = (maxAdj + minAdj) // 2
	if a[0] == -1:
		a[0] = k
	for i in range(1, n):
		if a[i] == -1:
			a[i] = k
		m = max(abs(a[i] - a[i - 1]), m)
	print(*[m, k])


import sys
from math import ceil, sqrt
read = sys.stdin.buffer.readline
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())

def isp(n):
	i = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += 1
	return True
primes = []
for _ in range(cin()):
	n = cin()
	a = li()
	(mn, mx) = (max(a), -2)
	for i in range(n):
		if a[i] == -1:
			if i > 0 and a[i - 1] != -1:
				mx = max(a[i - 1], mx)
				mn = min(mn, a[i - 1])
			if i + 1 < n and a[i + 1] != -1:
				mx = max(a[i + 1], mx)
				mn = min(mn, a[i + 1])
	k = (mx + mn) // 2
	if mn == -1 and mx == -2:
		k = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	m = 0
	for i in range(1, n):
		m = max(m, abs(a[i] - a[i - 1]))
	print(m, k)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = []
	f2 = True
	for i in range(n):
		if a[i] != -1:
			f2 = False
			break
	if f2:
		print(0, 0)
		continue
	for i in range(n - 1):
		if a[i] == -1 and a[i + 1] == -1:
			pass
		elif a[i] == -1:
			ans.append(a[i + 1])
		elif a[i + 1] == -1:
			ans.append(a[i])
	mi = min(ans)
	mx = max(ans)
	k = (mi + mx) // 2
	m = abs(mi - k)
	x = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(n - 1):
		x = max(x, abs(a[i] - a[i + 1]))
	print(max(x, m), k)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	num = 0
	s = 0
	m = 1000000010
	m1 = -1 * m
	for i in range(n):
		if a[i] == -1:
			if i - 1 >= 0:
				if a[i - 1] != -1:
					m = min(m, a[i - 1])
					m1 = max(m1, a[i - 1])
			if i + 1 < n:
				if a[i + 1] != -1:
					m = min(m, a[i + 1])
					m1 = max(m1, a[i + 1])
	k = (m + m1) // 2
	if a[0] == -1:
		a[0] = k
	ans = 0
	for i in range(1, n):
		if a[i] == -1:
			a[i] = k
		ans = max(abs(a[i] - a[i - 1]), ans)
	print(ans, k)


num_cases = int(input())
for case in range(num_cases):
	n = int(input())
	min_num = 1000000027
	max_num = 0
	biggest = 0
	nums = input().split()
	for i in range(len(nums)):
		nums[i] = int(nums[i])
	for i in range(len(nums)):
		curr_num = nums[i]
		prev_num = nums[i - 1]
		if curr_num == -1:
			if i != 0:
				if prev_num != -1:
					max_num = max(max_num, prev_num)
					min_num = min(min_num, prev_num)
			if i != len(nums) - 1:
				next_num = nums[i + 1]
				if next_num != -1:
					max_num = max(max_num, next_num)
					min_num = min(min_num, next_num)
		elif i != 0 and prev_num != -1:
			biggest = max(biggest, abs(curr_num - prev_num))
	if min_num > max_num:
		ans = max_num
	else:
		ans = (min_num + max_num) // 2
	print(max(biggest, max(ans - min_num, max_num - ans)), end=' ')
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mi = float('INF')
	ma = -float('INF')
	value = 0
	for i in range(n):
		if i > 0 and a[i] == -1 and (a[i - 1] != -1):
			mi = min(a[i - 1], mi)
			ma = max(ma, a[i - 1])
		if i < n - 1 and a[i] == -1 and (a[i + 1] != -1):
			mi = min(a[i + 1], mi)
			ma = max(ma, a[i + 1])
	value = (mi + ma) // 2
	if a.count(-1) == len(a):
		value = 0
	m = 0
	for (i, item) in enumerate(a):
		if a[i] == -1:
			a[i] = value
		if i:
			m = max(m, abs(a[i] - a[i - 1]))
	print(m, value)


import sys
t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, sys.stdin.readline().strip().split()))
	x = 0
	f = 1
	c = 0
	cc = 0
	a = [0] + b.copy() + [0]
	zzzz = set()
	for j in range(1, n + 1):
		if a[j] > -1:
			f = 0
		else:
			c += 1
		if a[j] > -1 and (a[j - 1] == -1 or a[j + 1] == -1):
			zzzz.add(a[j])
			cc += 1
	if f:
		print(0, 0)
		continue
	z = min(zzzz) + (max(zzzz) - min(zzzz)) // 2
	b1 = []
	b2 = []
	b3 = []
	b4 = []
	b5 = []
	for j in b:
		if j > -1:
			b1.append(j)
			b2.append(j)
			b3.append(j)
			b4.append(j)
			b5.append(j)
		else:
			b1.append(z)
			b2.append(z + 1)
			b3.append(z + 2)
			b4.append(z - 1)
			b5.append(z - 2)
	op1 = 0
	op2 = 0
	op3 = 0
	op4 = 0
	op5 = 0
	for j in range(1, n):
		op1 = max(op1, abs(b1[j] - b1[j - 1]))
		op2 = max(op2, abs(b2[j] - b2[j - 1]))
		op3 = max(op3, abs(b3[j] - b3[j - 1]))
		op4 = max(op4, abs(b4[j] - b4[j - 1]))
		op5 = max(op5, abs(b5[j] - b5[j - 1]))
	oop = min([op1, op2, op3, op4, op5])
	op = [op1, op2, op3, op4, op5]
	opact = [z, z + 1, z + 2, z - 1, z - 2]
	for j in range(5):
		if oop == op[j]:
			print(op[j], opact[j])
			break


t = int(input())
for i in range(t):
	n = int(input())
	lis = list(map(int, input().split()))
	maxi = 0
	tempLis = []
	for j in range(0, n - 1):
		if lis[j] != -1 and lis[j + 1] != -1:
			if abs(lis[j] - lis[j + 1]) > maxi:
				maxi = abs(lis[j] - lis[j + 1])
		elif lis[j] == -1 and lis[j + 1] != -1:
			tempLis.append(lis[j + 1])
		elif lis[j] != -1 and lis[j + 1] == -1:
			tempLis.append(lis[j])
	if len(tempLis) == 0:
		print(0, end=' ')
		print(0)
		continue
	tempMax = max(tempLis)
	tempMin = min(tempLis)
	k = int((tempMax + tempMin) / 2)
	m = max(maxi, abs(tempMax - k), abs(tempMin - k))
	print(m, end=' ')
	print(k)


import sys
sys.setrecursionlimit(10 ** 7)
T = int(input())

def calc(n, A):
	prev = A[0]
	m = 0
	k = 0
	nmin = 10 ** 9
	nmax = 0
	for i in range(1, n):
		ai = A[i]
		aip = A[i - 1]
		if ai == -1:
			if aip != -1:
				nmin = min(nmin, aip)
				nmax = max(nmax, aip)
		elif aip == -1:
			nmin = min(nmin, ai)
			nmax = max(nmax, ai)
		else:
			m = max(m, abs(ai - aip))
	if nmin != 10 ** 9 and nmax != 0:
		ndiff = nmax - nmin
		nm = -(-ndiff // 2)
		k = nmin + ndiff // 2
	else:
		nm = 0
		if nmin == 10 ** 9:
			k = nmax
		elif nmax == 0:
			k = nmin
	m = max(m, nm)
	return (m, k)
res = []
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	(m, k) = calc(n, A)
	res.append('{} {}'.format(m, k))
print('\n'.join(res))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	d = set()
	for (i, x) in enumerate(a):
		if x == -1:
			if i > 0:
				d.add(a[i - 1])
			if i < len(a) - 1:
				d.add(a[i + 1])
	d = [x for x in list(d) if x != -1]
	a2 = (min(d) + max(d)) // 2 if d else 0
	a = [x if x != -1 else a2 for x in a]
	print('%d %d' % (max([abs(a[x] - a[x + 1]) for x in range(len(a) - 1) if a[x] != -1 and a[x + 1] != -1]), a2))


t = input()
t = int(t)
while t:
	t -= 1
	n = input()
	a = input()
	a = [int(str) for str in a.split()]
	minn = 10000000000.0
	dist = -1
	maxx = -1
	for i in range(len(a)):
		cur = a[i]
		if cur == -1:
			if i == 0:
				if a[i + 1] != -1:
					minn = min(a[i + 1], minn)
					maxx = max(a[i + 1], maxx)
			elif i == len(a) - 1:
				if a[i - 1] != -1:
					minn = min(a[i - 1], minn)
					maxx = max(a[i - 1], maxx)
			else:
				if a[i + 1] != -1:
					minn = min(a[i + 1], minn)
					maxx = max(a[i + 1], maxx)
				if a[i - 1] != -1:
					minn = min(a[i - 1], minn)
					maxx = max(a[i - 1], maxx)
		elif i != 0 and a[i - 1] != -1:
			dist = max(dist, abs(a[i] - a[i - 1]))
	if maxx == -1:
		maxx = minn = 0
	k = (maxx + minn) // 2
	dist = max(dist, abs(k - maxx))
	print(dist, k)


from functools import reduce
import math
t = int(input())
for case in range(t):
	n = int(input())
	a = input()
	a = [int(i) for i in a.split(' ')]
	l = len(a)
	mn = 1000000001
	mx = -mn
	besto_k = besto_dif = 0
	for i in range(l):
		if i > 0 and a[i] == -1 and (a[i - 1] != -1):
			(mn, mx) = (min(mn, a[i - 1]), max(mx, a[i - 1]))
		if i < l - 1 and a[i] == -1 and (a[i + 1] != -1):
			(mn, mx) = (min(mn, a[i + 1]), max(mx, a[i + 1]))
	besto_k = (mx + mn) // 2
	for i in range(l):
		if a[i] == -1:
			a[i] = besto_k
		if i > 0:
			besto_dif = max(besto_dif, abs(a[i] - a[i - 1]))
	print(besto_dif, besto_k)


import atexit
import io
import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ma = 0
	mi = 1000000000
	m = 0
	flag = 0
	for j in range(n):
		if a[j] != -1:
			flag = 1
			if j - 1 >= 0 and a[j - 1] == -1:
				ma = max(ma, a[j])
				mi = min(mi, a[j])
			elif j - 1 >= 0:
				m = max(m, abs(a[j] - a[j - 1]))
			if j + 1 < n and a[j + 1] == -1:
				ma = max(ma, a[j])
				mi = min(mi, a[j])
	if flag == 0:
		print(0, 0)
	else:
		s = (mi + ma) // 2
		m = max(m, abs(s - mi), abs(s - ma))
		print(m, s)


import os
import sys
from math import *
from collections import *
from fractions 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')

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 = set()
	for i in range(n):
		if a[i] != -1 and i != 0 and (a[i - 1] == -1):
			ans.add(a[i])
		if a[i] != -1 and i != n - 1 and (a[i + 1] == -1):
			ans.add(a[i])
	try:
		ans = (min(ans) + max(ans)) // 2
	except:
		ans = 0
	a1 = list(map(lambda x: x if x != -1 else ans, a))
	a2 = list(map(lambda x: x if x != -1 else ans + 1, a))
	(maxDif1, maxDif2) = (0, 0)
	for i in range(n - 1):
		maxDif1 = max(maxDif1, abs(a1[i] - a1[i + 1]))
		maxDif2 = max(maxDif2, abs(a2[i] - a2[i + 1]))
	maxDif = maxDif1
	if maxDif2 < maxDif1:
		maxDif = maxDif2
		ans += 1
	print(maxDif, ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	adj_numbers = set()
	for (ind, x) in enumerate(l):
		if x == -1:
			if ind > 0 and l[ind - 1] != -1:
				adj_numbers.add(l[ind - 1])
			if ind < n - 1 and l[ind + 1] != -1:
				adj_numbers.add(l[ind + 1])
	if len(adj_numbers) == 0:
		print(0, 0)
		continue
	minn = min(adj_numbers)
	maxx = max(adj_numbers)
	avg = int(math.floor((minn + maxx) / 2.0))
	m = float('-inf')
	for i in range(n):
		if l[i] == -1:
			l[i] = avg
	for i in range(1, n):
		m = max(abs(l[i] - l[i - 1]), m)
	print(m, avg)


from math import *
t = int(input())
for y in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(-1) == n:
		print(0, 0)
	else:
		m1 = 1000000000.0 + 8
		m2 = -2
		for i in range(n):
			if a[i] != -1:
				if i != n - 1 and a[i + 1] == -1:
					m2 = max(a[i], m2)
					m1 = min(a[i], m1)
				if i != 0 and a[i - 1] == -1:
					m2 = max(a[i], m2)
					m1 = min(a[i], m1)
		x = (m1 + m2) // 2
		for i in range(n):
			if a[i] == -1:
				a[i] = x
		ans = 0
		for i in range(1, n):
			ans = max(ans, abs(a[i] - a[i - 1]))
		print(ans, x)


from math import ceil
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = 0
	mmax = 0
	mmin = 1000000000.0
	diff1 = -1
	for i in range(len(a) - 1):
		if a[i] == -1 and a[i + 1] != -1:
			cnt += 1
			mmax = max(mmax, a[i + 1])
			mmin = min(mmin, a[i + 1])
		elif a[i] != -1 and a[i + 1] == -1:
			cnt += 1
			mmax = max(mmax, a[i])
			mmin = min(mmin, a[i])
		else:
			diff1 = max(diff1, abs(a[i] - a[i + 1]))
	if not cnt:
		print('0 0')
		continue
	k = (mmax + mmin) // 2
	print(max(abs(mmax - k), abs(mmin - k), diff1), k)


def go():
	n = int(input())
	a = list(map(int, input().split()))
	(mn, mx) = (100000000000, -1)
	m = -1
	for i in range(n):
		if i > 0 and a[i] != -1 and (a[i - 1] != -1):
			m = max(m, abs(a[i] - a[i - 1]))
		if a[i] == -1:
			if i > 0 and a[i - 1] != -1:
				mn = min(mn, a[i - 1])
				mx = max(mx, a[i - 1])
			if i < n - 1 and a[i + 1] != -1:
				mn = min(mn, a[i + 1])
				mx = max(mx, a[i + 1])
	if mx == -1:
		return '0 0'
	k = (mn + mx) // 2
	return f'{max(k - mn, mx - k, m)} {k}'
t = int(input())
for _ in range(t):
	print(go())


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mi = min(a)
	ma = max(a)
	maxe = -1
	mine = -1
	if ma == -1:
		print(0, 0)
		continue
	ma = -1000000079404
	mi = 6584949003033
	for i in range(len(a) - 1):
		if a[i] != -1 and a[i + 1] == -1:
			if mi > a[i]:
				mi = a[i]
			if ma < a[i]:
				ma = a[i]
		if a[i + 1] != -1 and a[i] == -1:
			if mi > a[i + 1]:
				mi = a[i + 1]
			if ma < a[i + 1]:
				ma = a[i + 1]
		if a[i + 1] != -1 and a[i] != -1:
			if maxe < abs(a[i + 1] - a[i]):
				maxe = abs(a[i] - a[i + 1])
	printch = (mi + ma) // 2
	if maxe != -1:
		if maxe >= ma - printch:
			print(maxe, printch)
		else:
			print(ma - printch, printch)
	else:
		print(ma - printch, printch)


import math
t = int(input())
while t > 0:
	n = int(input())
	a = list(map(int, input().split()))
	sum1 = 0
	count = 0
	a1 = []
	for i in a:
		a1.append(i)
	for i in a:
		if i > 0:
			sum1 += i
			count += 1
	if count == 0:
		print(0, 0)
	else:
		l = []
		count = 0
		for i in range(0, n):
			if a1[i] == -1:
				if i + 1 < n:
					if a1[i + 1] != '*' and a1[i + 1] != -1:
						l.append(a1[i + 1])
						count += 1
						a1[i + 1] = '*'
			elif i + 1 < n:
				if a1[i + 1] == -1 and (a1[i] != '*' and a1[i] != -1):
					l.append(a1[i])
					count += 1
					a1[i] == '*'
		avg = (max(l) + min(l)) // 2
		for i in range(0, n):
			if a[i] == -1:
				a[i] = avg
		max1 = 0
		for i in range(1, n):
			d = abs(a[i] - a[i - 1])
			max1 = max(d, max1)
		print(max1, avg)
	t = t - 1


def cmax(a, b):
	if a > b:
		return a
	else:
		return b

def cmin(a, b):
	if a > b:
		return b
	else:
		return a
t = int(input())
for tt in range(t):
	n = int(input())
	(L, R) = (int(1000000000), int(0))
	(ans, cnt) = (0, 0)
	a = [int(x) for x in input().split()]
	for i in range(n):
		if i > 0 and a[i] != -1 and (a[i - 1] != -1):
			ans = cmax(ans, abs(a[i] - a[i - 1]))
		if a[i] != -1:
			continue
		cnt = cnt + 1
		if i > 0 and a[i - 1] != -1:
			L = cmin(L, a[i - 1])
			R = cmax(R, a[i - 1])
		if i != n - 1 and a[i + 1] != -1:
			L = cmin(L, a[i + 1])
			R = cmax(R, a[i + 1])
	if cnt == n:
		ans = L = R = 0
	ans = cmax(ans, (R - L + 1) // 2)
	print(ans, (L + R) // 2)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(l, h) = (1000010000, -1)
	for i in range(n):
		if a[i] >= 0:
			if i and a[i - 1] < 0 or (i + 1 < n and a[i + 1] < 0):
				l = min(l, a[i])
				h = max(h, a[i])
	if l > h:
		print(0, 0)
	else:
		x = (l + h) // 2
		y = h - x
		for i in range(1, n):
			if a[i - 1] >= 0 and a[i] >= 0:
				y = max(y, abs(a[i] - a[i - 1]))
		print(y, x)


t = int(input())
for i in range(t):
	n = int(input())
	mx = 0
	mn = 991000000000
	sred = 0
	m = list(map(int, input().split()))
	for i in range(n):
		if m[i] == -1:
			continue
		if i != 0:
			if m[i - 1] == -1:
				if mx < m[i]:
					mx = m[i]
				if mn > m[i]:
					mn = m[i]
			elif abs(m[i - 1] - m[i]) > sred:
				sred = abs(m[i - 1] - m[i])
			if i != n - 1:
				if m[i + 1] == -1:
					if mx < m[i]:
						mx = m[i]
					if mn > m[i]:
						mn = m[i]
				elif abs(m[i + 1] - m[i]) > sred:
					sred = abs(m[i + 1] - m[i])
		elif m[i + 1] == -1:
			if mx < m[i]:
				mx = m[i]
			if mn > m[i]:
				mn = m[i]
		elif abs(m[i + 1] - m[i]) > sred:
			sred = abs(m[i + 1] - m[i])
	r = mx + mn
	if mn > 1000000000:
		print(0, 0)
		continue
	if sred > max(mx - r // 2, r // 2 - mn):
		print(sred, r // 2)
	else:
		print(max(mx - r // 2, r // 2 - mn), r // 2)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	vals = []
	for i in range(n):
		if (i - 1 >= 0 and a[i - 1] == -1 or (i + 1 < n and a[i + 1] == -1)) and a[i] != -1:
			vals.append(a[i])
	if len(vals) == 0:
		print(0, 0)
	else:
		mid = (min(vals) + max(vals)) // 2
		maxResult = float('-inf')
		for i in range(n):
			if a[i] == -1:
				a[i] = mid
		for i in range(1, n):
			maxResult = max(maxResult, abs(a[i - 1] - a[i]))
		print(maxResult, mid)


def solve(n, l):
	l.append(-2)
	i = 0
	while l[i] == -1:
		i += 1
	if l[i] == -2:
		return [0, 0]
	l.insert(0, l[i])
	l.pop()
	j = len(l) - 1
	while l[j] == -1:
		j -= 1
	l.append(l[j])
	n = len(l)
	i = 0
	j = 0
	mmax = -1
	mmin = 10 ** 9 + 1
	while j < n:
		while i < n and l[i] == -1:
			i += 1
		j = i + 1
		while j < n and l[j] == -1:
			j += 1
		if j >= n:
			break
		if j == i + 1:
			i = j
			continue
		mmin = min(mmin, min(l[i], l[j]))
		mmax = max(mmax, max(l[i], l[j]))
		i = j
	res = 0
	k = (mmin + mmax) // 2
	for i in range(1, n):
		if l[i] == -1:
			l[i] = k
		res = max(res, abs(l[i] - l[i - 1]))
	return [res, k]
for t in range(int(input())):
	n = int(input())
	l = [int(i) for i in input().split()]
	res = solve(n, l)
	print(res[0], res[1])


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	mn = -1e+18
	for i in range(n - 1):
		if a[i] == -1 and a[i + 1] == -1:
			continue
		elif a[i] == -1:
			b.append(abs(0 - a[i + 1]))
		elif a[i + 1] == -1:
			b.append(abs(0 - a[i]))
		elif a[i + 1] != -1 and a[i] != -1:
			mn = max(abs(a[i + 1] - a[i]), mn)
	b.sort()
	if len(b) == 0:
		print(0, 0)
		continue
	md = (b[0] + b[-1]) // 2
	for i in range(n - 1):
		if a[i] != -1 and a[i + 1] != -1:
			mn = max(abs(a[i + 1] - a[i]), mn)
		elif a[i] == -1 and a[i + 1] == -1:
			mn = max(mn, 0)
		elif a[i] == -1 and a[i + 1] != -1:
			mn = max(mn, abs(a[i + 1] - md))
		else:
			mn = max(mn, abs(a[i] - md))
	print(mn, md)


def calc(A):
	(min_, max_) = (float('Inf'), 0)
	found = False
	for (i, a) in enumerate(A):
		if a != -1:
			continue
		if 0 <= i - 1 and A[i - 1] != -1:
			found = True
			min_ = min(min_, A[i - 1])
			max_ = max(max_, A[i - 1])
		if i + 1 < len(A) and A[i + 1] != -1:
			found = True
			min_ = min(min_, A[i + 1])
			max_ = max(max_, A[i + 1])
	k = (min_ + max_) // 2 if found else 0
	res = 0
	for i in range(len(A)):
		if A[i] == -1:
			A[i] = k
		if i > 0:
			res = max(res, abs(A[i] - A[i - 1]))
	return (res, k)
N = int(input())
cases = []
for _ in range(N):
	d = int(input())
	cases.append(list(map(int, input().split())))
for c in cases:
	r = calc(c)
	print('{} {}'.format(r[0], r[1]))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(ans, small, big) = (0, 2 * 10 ** 9, -1)
	for i in range(len(a) - 1):
		if a[i] == -1 and a[i + 1] != -1:
			small = min(small, a[i + 1])
			big = max(big, a[i + 1])
		if a[i] != -1 and a[i + 1] == -1:
			small = min(small, a[i])
			big = max(big, a[i])
		if a[i] != -1 and a[i + 1] != -1:
			ans = max(ans, abs(a[i] - a[i + 1]))
	if big == -1:
		print(ans, 0)
	else:
		x = (small + big) // 2
		ans = max(ans, abs(big - x))
		ans = max(ans, abs(x - small))
		print(ans, x)


t = int(input())
for s in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	i = 1
	(maxi, maxu, mini, d) = (0, 0, 999999999, 0)
	while i < n:
		if a[i] != -1 and a[i - 1] != -1:
			d = a[i] - a[i - 1]
			if d < 0:
				d = d * -1
			maxi = max(maxi, d)
		else:
			maxu = max(maxu, a[i], a[i - 1])
			if a[i] != -1:
				mini = min(mini, a[i])
			elif a[i - 1] != -1:
				mini = min(mini, a[i - 1])
		i += 1
	if mini == 999999999:
		mini = 0
	dif = maxu - mini
	if dif > 2 * maxi:
		print(dif - dif // 2, end=' ')
		print((maxu + mini) // 2)
	else:
		print(maxi, end=' ')
		print((maxu + mini) // 2)


tc = int(input())
for T in range(tc):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = []
	for i in range(n):
		if arr[i] != -1:
			if i == 0:
				if arr[i + 1] == -1:
					temp.append(arr[i])
			elif i == n - 1:
				if arr[i - 1] == -1:
					temp.append(arr[i])
			elif arr[i + 1] == -1 or arr[i - 1] == -1:
				temp.append(arr[i])
	siz = len(temp)
	if siz >= 2:
		temp.sort()
		snd = (temp[0] + temp[siz - 1]) // 2
	elif siz == 0:
		snd = 0
	else:
		snd = temp[0]
	for i in range(n):
		if arr[i] == -1:
			arr[i] = snd
	fst = -1
	for i in range(n - 1):
		dif = abs(arr[i] - arr[i + 1])
		fst = max(fst, dif)
	print(fst, snd)


num_t = int(input())
for _ in range(num_t):
	input()
	arr = [int(i) for i in input().split()]
	min_p = float('inf')
	max_p = float('-inf')
	found = False
	for i in range(len(arr)):
		if arr[i] == -1 and i - 1 >= 0 and (arr[i - 1] != -1):
			min_p = min(arr[i - 1], min_p)
			max_p = max(arr[i - 1], max_p)
			found = True
		if arr[i] == -1 and i + 1 < len(arr) and (arr[i + 1] != -1):
			min_p = min(arr[i + 1], min_p)
			max_p = max(arr[i + 1], max_p)
			found = True
	if not found:
		print(0, 0)
		continue
	k = (max_p + min_p) // 2
	m = float('-inf')
	for i in range(1, len(arr)):
		if arr[i] != -1 and arr[i - 1] != -1:
			m = max(abs(arr[i] - arr[i - 1]), m)
	print(max(m, max_p - k, k - min_p), k)


import os
import sys
from io import BytesIO, IOBase

def solve(n, m):
	if m == 0:
		return 0
	z = n - m
	ans = n * (n + 1) // 2
	(k, l) = (z // (m + 1), z % (m + 1))
	ans -= l * (k + 1) * (k + 2) // 2
	ans -= (m + 1 - l) * (k + 1) * k // 2
	return ans

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		pvr = a[0]
		b = []
		ans = 0
		for x in a:
			if x == -1:
				if pvr == -1:
					continue
				b.append(pvr)
				pvr = x
			elif pvr == -1:
				b.append(x)
				pvr = x
				continue
			else:
				ans = max(ans, abs(x - pvr))
				pvr = x
		k = 0
		b.sort()
		if len(b) > 0:
			k = b[0] + b[-1]
			k //= 2
		for x in b:
			ans = max(ans, abs(x - k))
		print('%d %d' % (ans, k))
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 _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(mx, mn) = (-float('inf'), float('inf'))
	for i in range(n):
		if i > 0 and a[i] == -1 and (a[i - 1] != -1):
			(mx, mn) = (max(mx, a[i - 1]), min(mn, a[i - 1]))
		if i < n - 1 and a[i] == -1 and (a[i + 1] != -1):
			(mn, mx) = (min(mn, a[i + 1]), max(mx, a[i + 1]))
	if mx == -float('inf') or mn == float('inf'):
		ans = 0
	else:
		ans = (mx + mn) // 2
	m = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = ans
		if i > 0:
			m = max(m, abs(a[i] - a[i - 1]))
	print(m, ans)


numTestcases = int(input())
for i in range(numTestcases):
	n = int(input())
	array = list(map(int, input().split(' ')))
	cMin = 9999999999
	cMax = 0
	for c in range(n):
		if array[c] == -1:
			if c != 0 and array[c - 1] != -1:
				cMin = min(cMin, array[c - 1])
				cMax = max(cMax, array[c - 1])
			if c != n - 1 and array[c + 1] != -1:
				cMax = max(cMax, array[c + 1])
				cMin = min(cMin, array[c + 1])
	if cMin == 9999999999:
		print('0 0')
	else:
		k = (cMax - cMin) // 2 + cMin
		m = 0
		for i in range(1, n):
			firstNum = array[i - 1]
			if firstNum == -1:
				firstNum = k
			secondNum = array[i]
			if secondNum == -1:
				secondNum = k
			m = max(abs(secondNum - firstNum), m)
		print(str(m) + ' ' + str(k))


import sys
input = sys.stdin.readline
INF = 10 ** 16
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	A = list(map(int, input().split()))
	Query.append((N, A))
for (N, A) in Query:
	P = set()
	L = 0
	for i in range(N - 1):
		if A[i] == -1 and A[i + 1] == -1:
			continue
		elif A[i] == -1 and A[i + 1] != -1:
			P.add(A[i + 1])
		elif A[i] != -1 and A[i + 1] == -1:
			P.add(A[i])
		else:
			L = max(L, abs(A[i] - A[i + 1]))
	if not P:
		print(L, 0)
	else:
		l = -1
		r = 10 ** 14
		while r - l > 1:
			m = (r + l) // 2
			p1 = -INF
			p2 = INF
			for n in P:
				p1 = max(n - m, p1)
				p2 = min(n + m, p2)
			if p1 <= p2:
				r = m
			else:
				l = m
		p1 = -INF
		p2 = INF
		for n in P:
			p1 = max(n - r, p1)
			p2 = min(n + r, p2)
		print(max(r, L), p1)


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	a = [int(p) for p in input().split(' ')]
	m = 0
	s = set()
	for j in range(0, n):
		if a[j] == -1:
			if j > 0 and a[j - 1] != -1:
				s.add(a[j - 1])
			if j < n - 1 and a[j + 1] != -1:
				s.add(a[j + 1])
	s = list(s)
	s.sort()
	k = 0
	if s:
		k = (s[0] + s[-1]) // 2
	m = 0
	if a[0] == -1:
		a[0] = k
	for j in range(1, n):
		if a[j] == -1:
			a[j] = k
		m = max(m, abs(a[j] - a[j - 1]))
	ans.append([m, k])
for a in ans:
	print(int(a[0]), int(a[1]))


import math
import collections
import sys

def inpu():
	return input().split(' ')

def inti(a):
	for i in range(len(a)):
		a[i] = int(a[i])
	return a

def inp():
	a = inpu()
	a = inti(a)
	return a

def solution():
	n = int(input())
	a = list(map(int, input().split()))
	s = []
	for i in range(n):
		if i > 0 and a[i - 1] == -1 and (a[i] != -1):
			s.append(a[i])
		elif i < n - 1 and a[i + 1] == -1 and (a[i] != -1):
			s.append(a[i])
	s.sort()
	if len(s) == 0:
		print(0, 0)
		return
	k = (s[0] + s[-1]) // 2
	m = -1
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(n - 1):
		m = max(abs(a[i] - a[i + 1]), m)
	print(m, k)
for _ in range(int(input())):
	solution()


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for j in range(len(a)):
		if j == 0:
			if a[j + 1] == -1 and a[j] != -1:
				l.append(a[j])
		elif j == len(a) - 1:
			if a[j - 1] == -1 and a[j] != -1:
				l.append(a[j])
		elif (a[j - 1] == -1 or a[j + 1] == -1) and a[j] != -1:
			l.append(a[j])
	if len(l) == 0:
		k = 0
	else:
		k = (max(l) + min(l)) // 2
	for j in range(len(a)):
		if a[j] == -1:
			a[j] = k
	m = 0
	for j in range(len(a) - 1):
		if abs(a[j] - a[j + 1]) > m:
			m = abs(a[j] - a[j + 1])
	print(m, k)


import sys
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	curr = arr[0]
	max_diff = -1
	l = sys.maxsize
	r = -1
	for i in range(1, n):
		if arr[i] != -1 and arr[i - 1] != -1:
			max_diff = max(max_diff, abs(arr[i] - arr[i - 1]))
	for i in range(1, n):
		if arr[i] == -1:
			if arr[i - 1] != -1:
				if arr[i - 1] <= l:
					l = arr[i - 1]
				if arr[i - 1] > r:
					r = arr[i - 1]
		elif arr[i - 1] == -1:
			if arr[i] <= l:
				l = arr[i]
			if arr[i] > r:
				r = arr[i]
	if r == -1 and l == sys.maxsize:
		k = 0
		fin_diff = max(max_diff, 0)
	elif r == -1 or r == l:
		k = l
		fin_diff = max(max_diff, abs(k - l))
	elif l == sys.maxsize:
		k = r
		fin_diff = max(max_diff, abs(k - r))
	else:
		k = l + (r - l) // 2
		fin_diff = max(max_diff, max(abs(k - l), abs(k - r)))
	print(str(fin_diff) + ' ' + str(k))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	minimo = 100000000000
	maximo = 0
	for i in range(len(a)):
		if i > 0 and a[i] == -1 and (a[i - 1] != -1):
			minimo = min(minimo, a[i - 1])
			maximo = max(maximo, a[i - 1])
		if i < len(a) - 1 and a[i] == -1 and (a[i + 1] != -1):
			minimo = min(minimo, a[i + 1])
			maximo = max(maximo, a[i + 1])
	if minimo == 100000000000 and maximo == 0:
		res2 = 0
	else:
		res2 = int((minimo + maximo) / 2)
	a = [res2 if x == -1 else x for x in a]
	diff = 0
	for i in range(len(a) - 1):
		if abs(a[i] - a[i + 1]) > diff:
			diff = abs(a[i] - a[i + 1])
	print(diff, end=' ')
	print(res2)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	mx = -10000000000
	mn = 10000000000
	for i in range(n):
		if a[i] == -1:
			if i > 0 and a[i - 1] != -1:
				mn = min(a[i - 1], mn)
				mx = max(a[i - 1], mx)
			if i < n - 1 and a[i + 1] != -1:
				mn = min(a[i + 1], mn)
				mx = max(a[i + 1], mx)
	k = (mx + mn) // 2
	ans = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = k
		if i:
			ans = max(ans, abs(a[i] - a[i - 1]))
	print(ans, k)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(n):
		b.append(a[i])
	s = set()
	for i in range(n):
		if a[i] == -1:
			if i > 0 and i < n - 1:
				if a[i - 1] != -1:
					s.add(a[i - 1])
				if a[i + 1] != -1:
					s.add(a[i + 1])
			elif i == 0:
				if a[i + 1] != -1:
					s.add(a[i + 1])
			elif i == n - 1:
				if a[i - 1] != -1:
					s.add(a[i - 1])
	if len(s) == 0:
		k = 0
		m = 0
		for i in range(n):
			if a[i] == -1:
				a[i] = k
		for i in range(1, n):
			m = max(m, abs(a[i] - a[i - 1]))
		print(m, k)
	else:
		k = (max(s) + min(s)) // 2
		m = 0
		for i in range(n):
			if a[i] == -1:
				a[i] = k
		for i in range(1, n):
			m = max(m, abs(a[i] - a[i - 1]))
		print(m, k)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(-1) == n:
		print(0, 0)
	else:
		arr = []
		for i in range(1, n):
			if a[i] != -1 and a[i - 1] == -1:
				arr.append(a[i])
			elif a[i] == -1 and a[i - 1] != -1:
				arr.append(a[i - 1])
		avg = (max(arr) + min(arr)) // 2
		for i in range(n):
			if a[i] == -1:
				a[i] = avg
		maxi = abs(a[1] - a[0])
		for i in range(2, n):
			diff = abs(a[i] - a[i - 1])
			if diff > maxi:
				maxi = diff
		print(maxi, avg)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	m = 0
	for i in range(n):
		if a[i] == -1:
			if i > 0 and a[i - 1] != -1:
				b.append(a[i - 1])
			if i < n - 1 and a[i + 1] != -1:
				b.append(a[i + 1])
	if len(b) != 0:
		m = (max(b) + min(b)) // 2
	c = [m if j == -1 else j for j in a]
	k = 0
	for t in range(n - 1):
		k = max(k, abs(c[t + 1] - c[t]))
	print(k, m)


import sys, math
MOD = 998244353

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	s = set()
	for i in range(n):
		if a[i] != -1:
			continue
		if 0 < i and a[i - 1] != -1:
			s.add(a[i - 1])
		if i + 1 < n and a[i + 1] != -1:
			s.add(a[i + 1])
	if len(s) == 0:
		return '{} {}'.format(0, 0)
	k = (max(s) + min(s)) // 2
	ans = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(1, n):
		ans = max(ans, abs(a[i] - a[i - 1]))
	return '{} {}'.format(ans, k)
for test in range(1, int(input()) + 1):
	print(solve())


for l in range(int(input(''))):
	a = input('')
	l = list(map(int, input('').split(' ')))
	z = []
	maxDist = 0
	for x in range(len(l)):
		appended = False
		if l[x] != -1:
			if x > 0:
				if l[x - 1] == -1:
					z.append(l[x])
					appended = True
				elif abs(l[x] - l[x - 1]) > maxDist:
					maxDist = abs(l[x] - l[x - 1])
			if appended == False:
				if x < len(l) - 1:
					if l[x + 1] == -1:
						z.append(l[x])
	if len(z) > 0:
		k = int((min(z) + max(z)) / 2)
		if max(z) - k > maxDist:
			maxDist = max(z) - k
		if k - min(z) > maxDist:
			maxDist = k - min(z)
		print(str(maxDist) + ' ' + str(k))
	else:
		print(str(maxDist) + ' ' + '0')


for t in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	prev = -1
	k = -1
	diff = -1
	minimum = 9999999999999999999999
	maximum = -1
	for i in range(n):
		if arr[i] == -1:
			if i != 0 and arr[i - 1] != -1:
				minimum = min(minimum, arr[i - 1])
				maximum = max(maximum, arr[i - 1])
			if i != n - 1 and arr[i + 1] != -1:
				minimum = min(minimum, arr[i + 1])
				maximum = max(maximum, arr[i + 1])
	if maximum == -1:
		print(0, 0)
	else:
		k1 = minimum + (maximum - minimum) // 2
		diff1 = -1
		if arr[0] == -1:
			arr[0] = k1
		for i in range(1, n):
			if arr[i] == -1:
				arr[i] = k1
			diff1 = max(diff1, abs(arr[i] - arr[i - 1]))
		print(diff1, k1)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	res = []
	mx = 0
	mn = 0
	for i in range(n):
		if a[i] == -1:
			if i - 1 >= 0 and a[i - 1] != -1:
				res += [max(0, a[i - 1])]
			if i + 1 < n and a[i + 1] != -1:
				res += [max(0, a[i + 1])]
	if len(res):
		mn = min(res)
		mx = max(res)
	val = (mx + mn) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = val
	mx = -1
	for i in range(n - 1):
		res = abs(a[i] - a[i + 1])
		if res > mx:
			mx = res
	print(mx, val)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	minn = 10 ** 9
	maxx = 0
	t = 0
	for i in range(n - 1):
		if a[i] != -1 and a[i + 1] == -1:
			minn = min(a[i], minn)
			maxx = max(a[i], maxx)
		elif a[i] == -1 and a[i + 1] != -1:
			minn = min(a[i + 1], minn)
			maxx = max(a[i + 1], maxx)
		elif a[i] != -1 and a[i + 1] != -1:
			t = max(t, abs(a[i] - a[i + 1]))
	if minn == 10 ** 9:
		minn = 0
	mm = float('inf')
	kk = -1
	k = (maxx + minn) // 2
	m = max(abs(maxx - k), abs(minn - k), t)
	if m < mm:
		mm = m
		kk = k
	print(mm, kk)


t = int(input())
for itr in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	mx = -1000000010
	mn = 1000000010
	for i in range(n):
		if i > 0 and li[i] == -1 and (li[i - 1] != -1):
			mx = max(mx, li[i - 1])
			mn = min(mn, li[i - 1])
		if i < n - 1 and li[i] == -1 and (li[i + 1] != -1):
			mx = max(mx, li[i + 1])
			mn = min(mn, li[i + 1])
	k = int((mx + mn) / 2)
	if mx == -1000000010:
		k = 0
	m = 0
	for i in range(n):
		if li[i] == -1:
			li[i] = k
		if i > 0:
			m = max(m, abs(li[i] - li[i - 1]))
	print(m, k)


t = int(input())
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	L = []
	m = 0
	now = A[0]
	for a in A[1:]:
		if now == -1:
			if a != -1:
				L.append(a)
				now = a
		elif a == -1:
			L.append(now)
			now = -1
		else:
			m = max(m, abs(a - now))
			now = a
	L.sort()
	if L:
		k = (L[-1] + L[0]) // 2
		m = max(m, L[-1] - k)
	else:
		k = 0
		m = 0
	print(m, k)


def ceil(a):
	if a // 1 == a:
		return int(a)
	else:
		return int(a) + 1
for _ in range(0, int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = len(a)
	m = 0
	li = []
	for i in range(0, l - 1):
		if a[i] != -1 and a[i + 1] == -1:
			li.append(a[i])
		if a[i + 1] != -1 and a[i] == -1:
			li.append(a[i + 1])
		if a[i + 1] != -1 and a[i] != -1:
			if abs(a[i + 1] - a[i]) > m:
				m = abs(a[i + 1] - a[i])
	li.sort()
	if len(li) == 0:
		print(0, 0)
	else:
		k = (+li[0] + li[-1]) // 2
		m = max(abs(k - li[0]), abs(k - li[-1]), m)
		print(m, k)


import sys
input = sys.stdin.readline
t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	l = []
	start = 0
	end = 0
	done = 0
	for i in range(n):
		if li[i] == -1:
			if done:
				end += 1
			else:
				start = i
				end = i
				done = 1
		elif done:
			l.append((start, end))
			done = 0
	if done:
		l.append((start, end))
		done = 0
	lo = []
	maxa = 0
	for i in l:
		n1 = i[0]
		n2 = i[1]
		if n1 > 0:
			lo.append(li[n1 - 1])
		if n2 < n - 1:
			lo.append(li[n2 + 1])
	if lo == []:
		ans = 0
	elif len(lo) == 1:
		ans = lo[0]
	else:
		lo.sort()
		ans = (lo[0] + lo[-1]) // 2
	for i in range(n):
		if li[i] == -1:
			li[i] = ans
	maxa = 0
	for i in range(1, n):
		maxa = max(maxa, abs(li[i] - li[i - 1]))
	print(maxa, end=' ')
	print(ans)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	ar = [-2] + a + [-2]
	r = []
	for i in range(1, n + 2):
		if ar[i] > -1 and (ar[i - 1] == -1 or ar[i + 1] == -1):
			r.append(ar[i])
	(ans, m) = (0, 0)
	if not r == []:
		ans = (max(r) + min(r)) // 2
		a = [*map(lambda x: ans if x == -1 else x, a)]
		m = max([abs(a[i] - a[i - 1]) for i in range(1, n)])
	print(m, ans)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	p = 10 ** 10
	o = -2
	for i in range(n):
		if a[i] != -1:
			if i == 0 and a[i + 1] == -1:
				o = max(a[i], o)
				p = min(a[i], p)
			elif i == n - 1 and a[i - 1] == -1:
				o = max(a[i], o)
				p = min(a[i], p)
			elif i != 0 and i != n - 1:
				if a[i - 1] == -1 or a[i + 1] == -1:
					o = max(a[i], o)
					p = min(a[i], p)
	if o == -2 and a[0] == -1:
		print(0, 0)
	else:
		m = 0
		for i in range(1, n):
			if a[i] != -1 and a[i - 1] != -1:
				m = max(m, abs(a[i] - a[i - 1]))
		t = (p + o) // 2
		print(max(m, abs(p - t), abs(o - t)), t)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	if a[0] != -1 and a[1] == -1:
		l.append(a[0])
	if a[-1] != -1 and a[-2] == -1:
		l.append(a[-1])
	for i in range(1, n - 1):
		if a[i] != -1 and (a[i - 1] == -1 or a[i + 1] == -1):
			l.append(a[i])
	if len(l) == 0:
		print(0, 0)
		continue
	m = (min(l) + max(l)) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = m
	print(max([abs(a[i] - a[i - 1]) for i in range(1, n)]), m)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	cnt = 0
	for i in arr:
		if i == -1:
			cnt += 1
	if cnt == n:
		print(0, 0)
	else:
		raj = set()
		for i in range(n):
			if arr[i] == -1:
				if i == 0:
					if arr[1] != -1:
						raj.add(1)
				elif i == n - 1:
					if arr[i - 1] != -1:
						raj.add(i - 1)
				else:
					if arr[i - 1] != -1:
						raj.add(i - 1)
					if arr[i + 1] != -1:
						raj.add(i + 1)
		tot = 0
		lol = []
		for i in raj:
			lol.append(arr[i])
		lol = sorted(lol)
		rep = (lol[0] + lol[-1]) // 2
		for i in range(n):
			if arr[i] == -1:
				arr[i] = rep
		check = [0] * (n - 1)
		for i in range(1, n):
			check[i - 1] = abs(arr[i] - arr[i - 1])
		print(max(check), rep)


for _ in range(int(input())):
	n = int(input())
	s = '-2 ' + input() + ' -2'
	l = [int(x) for x in s.split()]
	l1 = []
	max_abs = 0
	for i in range(1, n + 1):
		if l[i] > -1:
			if l[i - 1] == -1 or l[i + 1] == -1:
				l1.append(l[i])
			if l[i + 1] > -1:
				max_abs = max(max_abs, abs(l[i + 1] - l[i]))
	if len(l1) == 0:
		l1.append(0)
	ma = max(l1)
	mi = min(l1)
	ans = (ma + mi) // 2
	print(max(ma - ans, max_abs), ans)


for _ in range(int(input())):
	n = int(input())
	L = list(map(int, input().split()))
	R = []
	for i in range(n):
		if L[i] == -1:
			if i > 0 and L[i - 1] != -1:
				R.append(L[i - 1])
			if i < n - 1 and L[i + 1] != -1:
				R.append(L[i + 1])
	R.sort()
	if len(R) != 0:
		ans = (R[0] + R[-1]) // 2
	else:
		ans = 0
	for i in range(n):
		if L[i] == -1:
			L[i] = ans
	V = abs(L[0] - L[1])
	for i in range(n - 1):
		r = abs(L[i] - L[i + 1])
		if V < r:
			V = r
	print(V, ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = [a[0]]
	for j in range(1, n):
		if a[j] != -1:
			b.append(a[j])
		elif b[len(b) - 1] != -1:
			b.append(-1)
	if len(b) == 1:
		print(0, 0)
		continue
	mini = 10 ** 9 + 1
	maxi = -2
	for j in range(len(b) - 1):
		if b[j] == -1:
			if b[j + 1] > maxi:
				maxi = b[j + 1]
			if b[j + 1] < mini:
				mini = b[j + 1]
		elif b[j + 1] == -1:
			if b[j] > maxi:
				maxi = b[j]
			if b[j] < mini:
				mini = b[j]
	k = (maxi + mini) // 2
	m = -2
	for j in range(len(b) - 1):
		if b[j] == -1:
			b[j] = k
		if b[j + 1] == -1:
			b[j + 1] = k
		if abs(b[j + 1] - b[j]) > m:
			m = abs(b[j + 1] - b[j])
	print(m, k)


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	max1 = 0
	b = []
	for i in range(n - 1):
		if a[i] == -1 and a[i + 1] != -1:
			b.append(a[i + 1])
			continue
		if a[i] != -1 and a[i + 1] == -1:
			b.append(a[i])
			continue
		if abs(a[i] - a[i + 1]) > max1:
			max1 = abs(a[i] - a[i + 1])
	if b == []:
		print(max1, 0)
		continue
	max2 = (max(b) - min(b) + 1) // 2
	k = (max(b) + min(b)) // 2
	print(max(max1, max2), k)


from math import *
t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	if n == 2:
		if x[0] == -1 and x[-1] == -1:
			print(0, 0)
		else:
			print(0, max(x))
	else:
		f = 0
		mn = 10000000000.0
		mx = 0
		for i in range(n):
			if x[i] != -1:
				f = 1
				if i == 0:
					if x[i + 1] == -1:
						mn = min(mn, x[i])
						mx = max(mx, x[i])
				elif i == n - 1:
					if x[i - 1] == -1:
						mn = min(mn, x[i])
						mx = max(mx, x[i])
				elif x[i + 1] == -1 or x[i - 1] == -1:
					mn = min(mn, x[i])
					mx = max(mx, x[i])
		if f == 0:
			print(0, 0)
		else:
			k = (mn + mx) // 2
			for i in range(n):
				if x[i] == -1:
					x[i] = k
			m = 0
			for i in range(0, n - 1):
				m = max(m, abs(x[i] - x[i + 1]))
			print(m, k)


T = int(input())
for _ in range(0, T):
	N = int(input())
	s = [int(x) for x in input().split()]
	L = []
	for i in range(0, len(s)):
		if s[i] == -1:
			if i - 1 >= 0 and i - 1 < len(s):
				if s[i - 1] != -1:
					L.append(s[i - 1])
			if i + 1 >= 0 and i + 1 < len(s):
				if s[i + 1] != -1:
					L.append(s[i + 1])
	if len(L) == 0:
		print(0, 0)
	else:
		L = list(set(L))
		tot = min(L) + max(L)
		ele1 = tot // 2
		ele2 = tot // 2
		if tot % 2 != 0:
			ele2 += 1
		L1 = []
		L2 = []
		for i in range(0, len(s)):
			if s[i] == -1:
				L1.append(ele1)
				L2.append(ele2)
			else:
				L1.append(s[i])
				L2.append(s[i])
		mx1 = 0
		mx2 = 0
		for i in range(0, len(s) - 1):
			mx1 = max(mx1, abs(L1[i] - L1[i + 1]))
			mx2 = max(mx2, abs(L2[i] - L2[i + 1]))
		if mx1 <= mx2:
			print(mx1, ele1)
		else:
			print(mx2, ele2)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

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

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = ria()
		d = Counter(a)
		mx = 0
		w = 0
		p = []
		for i in range(n):
			if a[i] != -1:
				if i == 0:
					if a[i + 1] == -1:
						p.append(a[i])
				elif i == n - 1:
					if a[i - 1] == -1:
						p.append(a[i])
				elif a[i + 1] == -1 or a[i - 1] == -1:
					p.append(a[i])
		l = 0
		if len(p) != 0:
			l = (max(p) + min(p)) // 2
		z = [0] * n
		for i in range(n):
			if a[i] != -1:
				z[i] = a[i]
			else:
				z[i] = l
		ans = 0
		for i in range(1, n):
			ans = max(ans, abs(z[i] - z[i - 1]))
		print(ans, l)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


a = int(input())
for i in range(a):
	r = input()
	z = list(map(int, input().split()))
	t = []
	for i in range(len(z)):
		if z[i] == -1:
			if i > 0:
				if z[i - 1] != -1:
					t.append(z[i - 1])
			if i < len(z) - 1:
				if z[i + 1] != -1:
					t.append(z[i + 1])
	if len(t) == 0:
		k = 0
	else:
		k = (max(t) + min(t)) // 2
	for i in range(len(z)):
		if z[i] == -1:
			z[i] = k
	mini = 0
	for i in range(1, len(z)):
		if abs(z[i] - z[i - 1]) > mini:
			mini = abs(z[i] - z[i - 1])
	print(mini, k)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	mn = 10 ** 9 + 1
	mx = -2
	ans = 0
	for i in range(n):
		if l[i] == -1:
			if i - 1 >= 0 and l[i - 1] != -1:
				mx = max(mx, l[i - 1])
				mn = min(mn, l[i - 1])
			if i + 1 < n and l[i + 1] != -1:
				mn = min(mn, l[i + 1])
				mx = max(mx, l[i + 1])
		else:
			if i - 1 >= 0 and l[i - 1] != -1:
				ans = max(ans, abs(l[i] - l[i - 1]))
			if i + 1 < n and l[i + 1] != -1:
				ans = max(ans, abs(l[i] - l[i + 1]))
	v = 0
	if mn != 10 ** 9 + 1:
		v = mx - mn
		if v % 2 != 0:
			z = v // 2 + 1
		else:
			z = v // 2
		v = mx - z
		ans = max(ans, z)
	print(ans, v)


from math import ceil
for q in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	MIN = float('inf')
	MAX = -float('inf')
	if a[0] != -1 and a[1] == -1:
		MIN = min(MIN, a[0])
		MAX = max(MAX, a[0])
	if a[-1] != -1 and a[-2] == -1:
		MIN = min(MIN, a[-1])
		MAX = max(MAX, a[-1])
	for i in range(1, n - 1):
		if a[i] != -1 and (a[i - 1] == -1 or a[i + 1] == -1):
			MIN = min(MIN, a[i])
			MAX = max(MAX, a[i])
	if MIN == float('inf'):
		k = 0
	else:
		k = (MAX + MIN) // 2
	res = 0
	for i in range(n - 1):
		if a[i] == -1:
			a[i] = k
		if a[i + 1] == -1:
			a[i + 1] = k
		res = max(abs(a[i] - a[i + 1]), res)
	print(res, k)


import sys
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	minn = 10 ** 9
	maxx = -10 ** 9
	for i in range(n):
		if i > 0 and l[i] == -1 and (l[i - 1] != -1):
			minn = min(minn, l[i - 1])
			maxx = max(maxx, l[i - 1])
		if i < n - 1 and l[i] == -1 and (l[i + 1] != -1):
			minn = min(minn, l[i + 1])
			maxx = max(maxx, l[i + 1])
	k = (minn + maxx) // 2
	ans = 0
	for i in range(n):
		if l[i] == -1:
			l[i] = k
		if i:
			ans = max(ans, abs(l[i] - l[i - 1]))
	print(ans, k)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(n):
		if a[i] == -1:
			if i - 1 >= 0 and a[i - 1] != -1:
				b.append(a[i - 1])
			if i + 1 < n and a[i + 1] != -1:
				b.append(a[i + 1])
	if b == []:
		print(0, 0)
		continue
	x = max(b)
	y = min(b)
	z = (x + y) // 2
	diff = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = z
	for i in range(n - 1):
		diff = max(diff, abs(a[i] - a[i + 1]))
	print(diff, z)


from sys import maxsize

def checker(n, lst):
	(mx, mn) = (-maxsize, maxsize)
	for i in range(n):
		if i > 0 and lst[i] == -1 and (lst[i - 1] != -1):
			(mn, mx) = (min(mn, lst[i - 1]), max(mx, lst[i - 1]))
		if i < n - 1 and lst[i] == -1 and (lst[i + 1] != -1):
			(mn, mx) = (min(mn, lst[i + 1]), max(mx, lst[i + 1]))
	(result, answer) = ((mx + mn) // 2, 0)
	for i in range(n):
		if lst[i] == -1:
			lst[i] = result
		if i:
			answer = max(answer, abs(lst[i] - lst[i - 1]))
	return (answer, result)
for _ in range(int(input())):
	m = int(input())
	a = [int(j) for j in input().split()]
	print(*checker(m, a))


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = []
	ans = 0
	for i in range(n):
		if a[i] != -1:
			if i > 0 and a[i - 1] == -1 or (i < n - 1 and a[i + 1] == -1):
				a1.append(a[i])
			if i < n - 1 and a[i + 1] > -1:
				ans = max(ans, abs(a[i] - a[i + 1]))
	if not a1:
		a1.append(0)
	maxv = max(a1)
	minv = min(a1)
	k = (minv + maxv) // 2
	ans = max(maxv - k, ans)
	print(ans, k)


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		A = [int(x) for x in input().split()]
		x = set()
		for (a, b) in zip(A, A[1:]):
			if a == -1 and b != -1:
				x.add(b)
			if b == -1 and a != -1:
				x.add(a)
		y = 0
		if len(x) == 0:
			print(0, 0)
			continue
		elif len(x) == 1:
			y = max(x)
		else:
			y = (max(x) + min(x)) // 2
		ma = -float('inf')
		for (a, b) in zip(A, A[1:]):
			if a == -1 and b != -1:
				ma = max(abs(b - y), ma)
			if b == -1 and a != -1:
				ma = max(abs(a - y), ma)
			if a != -1 and b != -1:
				ma = max(abs(a - b), ma)
		print(ma, y)
main()


import math
for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	aa = []
	ans = 0
	for i in range(n):
		if lis[i] == -1:
			if i > 0 and lis[i - 1] != -1:
				aa.append(lis[i - 1])
			if i < n - 1 and lis[i + 1] != -1:
				aa.append(lis[i + 1])
	if len(aa) == 0:
		ans = 0
	else:
		ans = (max(aa) + min(aa)) // 2
	li = [ans if x == -1 else x for x in lis]
	k = k1 = 0
	for i in range(n - 1):
		k = max(k, abs(li[i] - li[i + 1]))
	print(k, ans)


T = int(input())
for t in range(T):
	n = int(input())
	A = [int(i) for i in input().split()]
	tmp = []
	if A[0] == -1 and A[1] != -1:
		tmp.append(A[1])
	for i in range(1, n - 1):
		if A[i] == -1:
			if A[i + 1] != -1:
				tmp.append(A[i + 1])
			if A[i - 1] != -1:
				tmp.append(A[i - 1])
	if A[-1] == -1 and A[-2] != -1:
		tmp.append(A[-2])
	if len(tmp) == 0:
		k = 0
	else:
		tmp = set(tmp)
		k = (min(tmp) + max(tmp)) // 2
	m = 0
	B = [A[i] if A[i] >= 0 else k for i in range(n)]
	for i in range(1, n):
		m = max(abs(B[i] - B[i - 1]), m)
	print(m, k)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		n = int(input())
		aa = [int(a) for a in input().split()]
		mn = int(1000000000.0)
		mx = -1
		mb = 0
		last = aa[0]
		lastgood = aa[0]
		for a in aa[1:]:
			if lastgood == -1 and a == -1:
				continue
			if a == -1 and last != -1:
				mx = max(mx, last)
				mn = min(mn, last)
			elif last == -1 and a != -1:
				mx = max(mx, a)
				mn = min(mn, a)
			elif a != -1:
				mb = max(mb, abs(a - lastgood))
			if a != -1:
				lastgood = a
			last = a
		if lastgood == -1:
			print(0, 0)
			return
		k = (mn + mx) // 2
		m = max(mb, mx - k)
		print(m, k)
	q = int(input())
	for _ in range(q):
		solve()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	sm = 0
	for i in range(n - 1):
		if l[i] != -1 and l[i + 1] != -1:
			m = abs(l[i] - l[i + 1])
			sm = max(m, sm)
	r = []
	if l[0] == -1 and l[1] != -1:
		r.append(l[1])
	if l[n - 1] == -1 and l[n - 2] != -1:
		r.append(l[n - 2])
	for i in range(1, n - 1):
		if l[i] == -1:
			if l[i + 1] != -1:
				r.append(l[i + 1])
			if l[i - 1] != -1:
				r.append(l[i - 1])
	r.sort()
	p = len(r)
	if p > 0:
		k = r[p - 1] - r[0]
		k = k // 2
		k = k + r[0]
		mx = max(r[p - 1] - k, k - r[0])
	else:
		mx = sm
		k = 0
	sm = max(mx, sm)
	print(sm, k)


t = int(input())
while t != 0:
	n = int(input())
	list1 = list(map(int, input().split()))
	u = []
	for i in range(len(list1)):
		if list1[i] != -1:
			if i > 0 and list1[i - 1] == -1 or (i < n - 1 and list1[i + 1] == -1):
				u.append(list1[i])
	(p, q) = (0, 0)
	if len(u) > 0:
		p = max(u)
		q = min(u)
	else:
		p = 0
		q = 0
	ans = (p + q) // 2
	maxi = 0
	if list1[0] == -1:
		list1[0] = ans
	for i in range(1, len(list1)):
		if list1[i] == -1:
			list1[i] = ans
			maxi = max(maxi, abs(list1[i] - list1[i - 1]))
		else:
			maxi = max(maxi, abs(list1[i] - list1[i - 1]))
	print(maxi, ans)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	p = []
	for i in range(1, n - 1):
		if (l[i - 1] == -1 or l[i + 1] == -1) and l[i] != -1:
			p.append(l[i])
	if l[1] == -1 and l[0] != -1:
		p.append(l[0])
	if l[n - 2] == -1 and l[n - 1] != -1:
		p.append(l[n - 1])
	if p == []:
		print(0, 0)
	else:
		if len(p) == 1:
			k = p[0]
		else:
			k = (max(p) + min(p)) // 2
		for i in range(n):
			if l[i] == -1:
				l[i] = k
		m = 0
		for i in range(1, n):
			if abs(l[i] - l[i - 1]) > m:
				m = abs(l[i] - l[i - 1])
		print(m, k)


import sys, math
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def getInts():
	return [int(s) for s in input().split()]

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

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
import collections as col
import math

def solve():
	N = getInt()
	A = getInts()
	max_A = -10 ** 18
	min_A = 10 ** 18
	if A == [-1] * N:
		print(0, 0)
		return
	for i in range(N):
		if i > 0 and A[i - 1] == -1 and (A[i] != -1):
			max_A = max(max_A, A[i])
			min_A = min(min_A, A[i])
		if i < N - 1 and A[i + 1] == -1 and (A[i] != -1):
			max_A = max(max_A, A[i])
			min_A = min(min_A, A[i])
	targ = (max_A + min_A) // 2
	for i in range(N):
		if A[i] == -1:
			A[i] = targ
	ans = 0
	for i in range(N - 1):
		ans = max(ans, abs(A[i + 1] - A[i]))
	print(ans, targ)
	return
for t in range(getInt()):
	solve()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(-1) == n:
		print(0, 0)
	else:
		b = []
		if a[0] == -1 and a[1] != -1 or (a[0] != -1 and a[1] == -1):
			b.append(a[1] if a[1] != -1 else a[0])
		if a[-1] == -1 and a[-2] != -1 or (a[-2] == -1 and a[-1] != -1):
			b.append(a[-2] if a[-2] != -1 else a[-1])
		for i in range(1, n - 1):
			if a[i] != -1:
				if a[i + 1] == -1 or a[i - 1] == -1:
					b.append(a[i])
		k = (max(b) + min(b)) // 2
		m = abs(k - max(b, key=lambda x: abs(x - k)))
		for i in range(n - 1):
			if a[i] != -1 and a[i + 1] != -1:
				m = max(m, abs(a[i] - a[i + 1]))
		print(m, k)


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input().strip()
mod = 1000000007
for i in range(I()):
	n = I()
	a = li()
	d = 0
	b = []
	for i in range(1, n - 1):
		if a[i] == -1:
			if a[i - 1] != -1:
				b.append(a[i - 1])
			if a[i + 1] != -1:
				b.append(a[i + 1])
	if a[0] == -1 and a[1] != -1:
		b.append(a[1])
	if a[-1] == -1 and a[-2] != -1:
		b.append(a[-2])
	b.sort()
	if len(b) == 0:
		print(0, 0)
		continue
	k = (b[0] + b[-1]) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(1, n):
		d = max(d, abs(a[i] - a[i - 1]))
	print(d, k)


import sys
input = sys.stdin.readline
import math
import copy
import collections
from collections import deque
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	adj = []
	if arr[0] != -1 and arr[1] == -1:
		adj.append(arr[0])
	if arr[-1] != -1 and arr[-2] == -1:
		adj.append(arr[-1])
	for i in range(1, n - 1):
		if (arr[i - 1] == -1 or arr[i + 1] == -1) and arr[i] != -1:
			adj.append(arr[i])
	if adj:
		k = (max(adj) + min(adj)) // 2
	else:
		k = 0
	for i in range(n):
		if arr[i] == -1:
			arr[i] = k
	m = 0
	for i in range(1, n):
		m = max(m, abs(arr[i] - arr[i - 1]))
	print(m, k)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	summ = 0
	cnt = 0
	arr = []
	if a[1] == -1 and a[0] != -1:
		arr.append(a[0])
	for i in range(1, n - 1):
		if a[i] != -1:
			if a[i - 1] == -1 or a[i + 1] == -1:
				arr.append(a[i])
	if a[-2] == -1 and a[-1] != -1:
		arr.append(a[-1])
	if arr:
		max1 = max(arr)
		min1 = min(arr)
		ans = (max1 + min1) // 2
		for i in range(n):
			if a[i] == -1:
				a[i] = ans
		maxx = -1
		for i in range(1, n):
			maxx = max(maxx, abs(a[i - 1] - a[i]))
		print(maxx, ans)
	else:
		print(0, 0)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = 1 if a[0] != -1 and a[1] == -1 else 0
	maxdif = 0
	max_ai = a[0] if a[0] != -1 and a[1] == -1 else 0
	min_ai = a[0] if a[0] != -1 and a[1] == -1 else 10 ** 9
	for i in range(1, n - 1):
		if a[i - 1] != -1 and a[i] != -1:
			maxdif = max(maxdif, abs(a[i] - a[i - 1]))
		if a[i] != -1 and (a[i - 1] == -1 or a[i + 1] == -1):
			min_ai = min(min_ai, a[i])
			max_ai = max(max_ai, a[i])
			cnt += 1
	if a[n - 2] != -1 and a[n - 1] != -1:
		maxdif = max(maxdif, abs(a[n - 1] - a[n - 2]))
	if a[n - 1] != -1 and a[n - 2] == -1:
		min_ai = min(min_ai, a[n - 1])
		max_ai = max(max_ai, a[n - 1])
		cnt += 1
	if cnt != 0:
		avg = (max_ai + min_ai) // 2
		print(max(max_ai - avg, maxdif), avg)
	else:
		print(0, 0)


def func(arr, n):
	mn = 2 ** 31 - 1
	mx = -2 ** 31
	for i in range(n):
		if i > 0 and arr[i] == -1 and (arr[i - 1] != -1):
			mn = min(mn, arr[i - 1])
			mx = max(mx, arr[i - 1])
		if i < n - 1 and arr[i] == -1 and (arr[i + 1] != -1):
			mn = min(mn, arr[i + 1])
			mx = max(mx, arr[i + 1])
	if mn == 2 ** 31 - 1:
		print(0, 0)
		return
	res = (mx + mn) // 2
	ans = 0
	for i in range(n):
		if arr[i] == -1:
			arr[i] = res
		if i:
			ans = max(ans, abs(arr[i] - arr[i - 1]))
	print(ans, res)
	return
T = int(input())
for _ in range(T):
	n = int(input())
	arr = list(map(int, input().split()))
	func(arr, n)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	deal = {}
	for i in range(n):
		if i < n - 1 and a[i] == -1 and (a[i + 1] != -1):
			deal[a[i + 1]] = True
		if i > 0 and a[i] == -1 and (a[i - 1] != -1):
			deal[a[i - 1]] = True
	dealers = deal.keys()
	if len(dealers) > 0:
		(mine, maxe) = (min(dealers), max(dealers))
		k = (mine + maxe) // 2
		m = max(abs(mine - k), abs(maxe - k))
		a = list(map(lambda x: x if x != -1 else k, a))
		for i in range(n - 1):
			m = max(m, abs(a[i] - a[i + 1]))
		print(m, k)
	else:
		print(0, 0)


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

def num():
	return int(input())
from itertools import repeat
from math import inf
t = num()
for _ in repeat(None, t):
	n = num()
	a = list(line())
	m1 = 0
	(qmin, qmax) = (inf, -1)
	for i in range(n):
		if a[i] == -1:
			if i - 1 >= 0 and a[i - 1] != -1:
				qmin = min(qmin, a[i - 1])
				qmax = max(qmax, a[i - 1])
			if i + 1 < n and a[i + 1] != -1:
				qmin = min(qmin, a[i + 1])
				qmax = max(qmax, a[i + 1])
		else:
			if i - 1 >= 0 and a[i - 1] != -1:
				m1 = max(m1, abs(a[i] - a[i - 1]))
			if i + 1 < n and a[i + 1] != -1:
				m1 = max(m1, abs(a[i] - a[i + 1]))
	k = (qmin + qmax) // 2
	m2 = max(k - qmin, qmax - k)
	if all((x == -1 for x in a)):
		print(0, 0)
	else:
		print(max(m1, m2), k)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	for i in range(n):
		if a[i] == -1:
			if i > 0 and a[i - 1] != -1:
				b.append(a[i - 1])
			if i < n - 1 and a[i + 1] != -1:
				b.append(a[i + 1])
	if len(b) == 0:
		z = 0
	else:
		z = (max(b) + min(b)) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = z
	k = abs(a[0] - a[1])
	for i in range(n - 1):
		if abs(a[i] - a[i + 1]) > k:
			k = abs(a[i] - a[i + 1])
	print(k, z)


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

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

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	l = li()
	mi = float('inf')
	ma = -float('inf')
	for i in range(n):
		if i > 0 and l[i] == -1 and (l[i - 1] != -1):
			mi = min(mi, l[i - 1])
			ma = max(ma, l[i - 1])
		if i < n - 1 and l[i] == -1 and (l[i + 1] != -1):
			mi = min(mi, l[i + 1])
			ma = max(ma, l[i + 1])
	if mi == float('inf') and ma == -float('inf'):
		print(0, 0)
		continue
	elif mi == float('inf'):
		print(ma, 0)
		continue
	elif ma == float('inf'):
		print(mi, 0)
		continue
	ans = (mi + ma) // 2
	for i in range(n):
		if l[i] == -1:
			l[i] = ans
	print(max((abs(l[i] - l[i - 1]) for i in range(1, n))), ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	adj = []
	ans = 0
	k = -1
	for j in range(n - 1):
		if a[j] == -1:
			if a[j + 1] != -1:
				adj.append(a[j + 1])
		elif a[j + 1] == -1:
			adj.append(a[j])
		elif abs(a[j] - a[j + 1]) > ans:
			ans = abs(a[j] - a[j + 1])
	if adj == []:
		print(ans, 0)
		continue
	adj.sort()
	if ans < adj[-1] - (adj[-1] + adj[0]) // 2:
		ans = adj[-1] - (adj[0] + adj[-1]) // 2
	print(ans, (adj[-1] + adj[0]) // 2)


from math import ceil
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = [max(l), -1]
	mini = -1
	if all((i == -1 for i in l)):
		print(0, 0)
		continue
	for i in range(n - 1):
		if l[i + 1] == -1 and l[i] != -1:
			m[:] = [min(l[i], m[0]), max(l[i], m[1])]
		elif l[i] == -1 and l[i + 1] != -1:
			m[:] = [min(l[i + 1], m[0]), max(l[i + 1], m[1])]
		else:
			mini = max(abs(l[i + 1] - l[i]), mini)
	mini = max(mini, ceil((m[1] - m[0]) / 2))
	print(mini, (m[1] + m[0]) // 2)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ls = []
	for i in range(n):
		if arr[i] == -1:
			continue
		if i < n - 1 and arr[i + 1] == -1 or (i > 0 and arr[i - 1] == -1):
			ls.append(arr[i])
	if ls == []:
		ls.append(0)
	var = (min(ls) + max(ls)) // 2
	m = 0
	for i in range(n - 1):
		if arr[i] == -1:
			arr[i] = var
		if arr[i + 1] == -1:
			arr[i + 1] = var
		ans = abs(arr[i] - arr[i + 1])
		m = max(m, ans)
	print(m, var)


def main():
	import sys
	input = sys.stdin.readline
	t = int(input())
	for _ in range(t):
		N = int(input())
		A = list(map(int, input().split()))
		B = []
		D = []
		for (i, a) in enumerate(A):
			if a == -1:
				if i != 0:
					if A[i - 1] >= 0:
						B.append(A[i - 1])
				if i != N - 1:
					if A[i + 1] >= 0:
						B.append(A[i + 1])
			elif i != 0:
				if A[i - 1] >= 0:
					D.append(abs(A[i] - A[i - 1]))
		if not B:
			print(0, 0)
			continue
		if D:
			d = max(D)
		else:
			d = 0
		B.sort()
		k = (B[-1] + B[0]) // 2
		print(max(B[-1] - k, d), k)
main()


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	arr = list(map(int, sys.stdin.readline().split()))
	a = set()
	for i in range(n):
		if arr[i] == -1:
			if i + 1 < n and arr[i + 1] != -1:
				a.add(arr[i + 1])
			if i - 1 >= 0 and arr[i - 1] != -1:
				a.add(arr[i - 1])
	if len(a) < 1:
		print(0, 0)
	else:
		(low, high) = (min(a), max(a))
		k = (low + high) // 2
		for i in range(n):
			if arr[i] == -1:
				arr[i] = k
		dif = 0
		for i in range(n - 1):
			dif = max(dif, abs(arr[i] - arr[i + 1]))
		print(dif, k)


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	B = []
	for i in range(N):
		if A[i] < 0:
			for d in [-1, 1]:
				x = i + d
				if 0 <= x < N and A[x] >= 0:
					B.append(A[x])
	if not B:
		print(0, 0)
	else:
		(x, y) = (max(B), min(B))
		m = (x + y) // 2
		diff = 0
		for i in range(N):
			if A[i] < 0:
				A[i] = m
		for i in range(N - 1):
			diff = max(diff, abs(A[i + 1] - A[i]))
		print(diff, m)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	tank = []
	for i in range(1, n - 1):
		if a[i] == -1:
			if a[i - 1] != -1:
				tank.append(a[i - 1])
			if a[i + 1] != -1:
				tank.append(a[i + 1])
	if a[0] == -1 and a[1] != -1:
		tank.append(a[1])
	if a[n - 1] == -1 and a[n - 2] != -1:
		tank.append(a[n - 2])
	tank.sort()
	if len(tank) == 1:
		k = tank[0]
	elif len(tank) == 0:
		k = 0
	else:
		k = (tank[-1] + tank[0]) // 2
	ma = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = k
		if i == 0:
			continue
		ma = max(ma, abs(a[i] - a[i - 1]))
	print(ma, k)


from sys import stdin, stdout

def maxDiff(a, k):
	t = [v if v != -1 else k for v in a]
	ret = 0
	for i in range(len(t) - 1):
		ret = max(ret, abs(t[i] - t[i + 1]))
	return ret
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	(mn, mx) = (float('inf'), -float('inf'))
	for (i, v) in enumerate(a):
		if a[i] != -1 and (i - 1 >= 0 and a[i - 1] == -1 or (i + 1 < n and a[i + 1] == -1)):
			(mn, mx) = (min(mn, v), max(mx, v))
	if mn == float('inf'):
		stdout.write('0 0\n')
	else:
		ret = mn + mx >> 1
		stdout.write('%d %d\n' % (maxDiff(a, ret), ret))


from math import *
zzz = int(input())
for zz in range(zzz):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = set()
	for i in range(n):
		if a[i] == -1:
			if i > 0:
				if a[i - 1] >= 0:
					b.add(a[i - 1])
			if i < n - 1:
				if a[i + 1] >= 0:
					b.add(a[i + 1])
	b = list(b)
	if len(b) == 0:
		print(0, 0)
	else:
		k = (min(b) + max(b)) // 2
		m = 0
		for i in range(n):
			if a[i] == -1:
				a[i] = k
		for i in range(1, n):
			m = max(m, abs(a[i - 1] - a[i]))
		print(m, k)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mx = -1
	b = 0
	mn = 1000000000
	for i in range(1, n - 1):
		if a[i] > mx and (a[i - 1] == -1 or a[i + 1] == -1):
			mx = a[i]
			b = 1
		if a[i] != -1 and mn > a[i] and (a[i - 1] == -1 or a[i + 1] == -1):
			mn = a[i]
			b = 1
	if a[0] > mx and n > 1:
		if a[1] == -1:
			mx = a[0]
			b = 1
	if a[n - 1] > mx and n > 1:
		if a[n - 2] == -1:
			mx = a[n - 1]
			b = 1
	if a[0] < mn and n > 1:
		if a[1] == -1 and a[0] != -1:
			mn = a[0]
			b = 1
	if a[n - 1] < mn and n > 1:
		if a[n - 2] == -1 and a[n - 1] != -1:
			mn = a[n - 1]
			b = 1
	k = int((mx + mn) / 2)
	max2 = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(n - 1):
		max2 = max(max2, abs(a[i] - a[i + 1]))
	if b == 0:
		print(0, 0, sep=' ')
	else:
		print(max2, k, sep=' ')


n = int(input())
for i in range(n):
	size = int(input())
	a = list(map(int, input().split()))
	ma = -1
	k = []
	for j in range(len(a) - 1):
		if a[j] == -1 and a[j + 1] != -1:
			k.append(a[j + 1])
		elif a[j] != -1 and a[j + 1] == -1:
			k.append(a[j])
		else:
			ma = max(ma, abs(a[j] - a[j + 1]))
	if len(k) == 0:
		print(0, 0)
	else:
		mini = min(k)
		maxi = max(k)
		print(max(ma, max(k) - (mini + (maxi - mini) // 2)), mini + (maxi - mini) // 2)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(item) for item in input().split()]
	max_val = 0
	min_val = 10 ** 12
	max_diff = 0
	for (a1, a2) in zip(a, a[1:]):
		if a1 == -1:
			if a2 == -1:
				continue
			else:
				max_val = max(max_val, a2)
				min_val = min(min_val, a2)
		elif a2 == -1:
			max_val = max(max_val, a1)
			min_val = min(min_val, a1)
		else:
			max_diff = max(max_diff, abs(a1 - a2))
	k = (max_val + min_val) // 2
	if min_val == 10 ** 12:
		k = 0
	m = max(max_diff, max_val - k, k - min_val)
	print(m, k)


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

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

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv(N, A):
	b = set()
	for i in range(N):
		if A[i] == -1:
			if i > 0 and A[i - 1] != -1:
				b.add(A[i - 1])
			if i < N - 1 and A[i + 1] != -1:
				b.add(A[i + 1])
	if not b:
		return '0 0'
	d = max(b) - min(b)
	m = min(b) + d // 2
	k = 0
	for i in range(N):
		if A[i] == -1:
			A[i] = m
	for i in range(1, N):
		k = max(k, abs(A[i] - A[i - 1]))
	return '%d %d' % (k, m)

def main():
	T = read_int()
	for _ in range(T):
		N = read_int()
		A = read_int_n()
		print(slv(N, A))
main()


from math import ceil

def hello_nigga():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		M = 0
		r = []
		if len(a) > 1:
			if a[1] == -1 and a[0] != -1:
				r = [a[0]]
		for i in range(1, n - 1):
			if a[i] != -1:
				if a[i - 1] == -1 or a[i + 1] == -1:
					r.append(a[i])
			if a[i] != -1 and a[i - 1] != -1:
				M = max(M, abs(a[i] - a[i - 1]))
		if a[-1] != -1 and a[-2] != -1:
			M = max(M, abs(a[-1] - a[-2]))
		if len(a) > 1:
			if a[-2] == -1 and a[-1] != -1:
				r.append(a[-1])
		if not r:
			print(M, 0)
			continue
		k = (min(r) + max(r)) // 2
		st = ''
		if st:
			k = r[0]
			var = 0
			c = 0
			d = 0
			for i in range(1, len(r)):
				tmp = abs(r[i] - r[i - 1])
				d = tmp
				k = tmp
				var += k
				c += 1
			if c:
				k = min(r) + ceil(var / c)
		D = 0
		for i in range(n):
			if a[i] == -1:
				a[i] = k
			if i > 0:
				D = max(D, abs(a[i] - a[i - 1]))
		print(D, k)
if 'compiler is alive':
	if 'it has sence' and 'the wether is nice':
		hello_nigga()


import math
from decimal import *
import random
import sys
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(mn, mx) = (int(1000000000.0), 0)
	mid = 0
	for i in range(n):
		if arr[i] != -1:
			if i > 0:
				if arr[i - 1] == -1:
					(mn, mx) = (min(mn, arr[i]), max(mx, arr[i]))
				elif i < n - 1:
					if arr[i + 1] == -1:
						(mn, mx) = (min(mn, arr[i]), max(mx, arr[i]))
			elif i < n - 1:
				if arr[i + 1] == -1:
					(mn, mx) = (min(mn, arr[i]), max(mx, arr[i]))
	if mn != int(1000000000.0) or mx != 0:
		mid = (mx + mn) // 2
	else:
		mid = 0
	for i in range(n):
		if arr[i] == -1:
			arr[i] = mid
	m = 0
	for i in range(n - 1):
		m = max(m, abs(arr[i] - arr[i + 1]))
	print(m, mid)


import sys
input = sys.stdin.readline
for _ in range(int(input().strip())):
	n = int(input().strip())
	arr = list(map(int, input().strip().split()))
	ne = []
	for i in range(n):
		if i == 0:
			if arr[i] == -1 and arr[i + 1] != -1:
				ne.append(arr[i + 1])
		elif i == n - 1:
			if arr[i] == -1 and arr[i - 1] != -1:
				ne.append(arr[i - 1])
		elif arr[i] == -1:
			if arr[i - 1] != -1:
				ne.append(arr[i - 1])
			if arr[i + 1] != -1:
				ne.append(arr[i + 1])
	ne.sort()
	(mi, ma) = (0, 0)
	if len(ne) == 1:
		(mi, ma) = (ne[0], ne[0])
	elif len(ne) > 1:
		(mi, ma) = (ne[0], ne[-1])
	k = (ma + mi) // 2
	ans = ma - k
	for i in range(n):
		if arr[i] == -1:
			arr[i] = k
	for i in range(n - 1):
		ans = max(ans, abs(arr[i] - arr[i + 1]))
	print(ans, k)


t = int(input())
(inf, minf) = (10 ** 18, -10 ** 18)
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(min_n, max_n) = (inf, minf)
	ans = 0
	for i in range(n):
		if a[i] == -1:
			if i + 1 < n and a[i + 1] > -1:
				min_n = min(min_n, a[i + 1])
				max_n = max(max_n, a[i + 1])
			if 0 <= i - 1 and a[i - 1] > -1:
				min_n = min(min_n, a[i - 1])
				max_n = max(max_n, a[i - 1])
		elif i + 1 < n and a[i + 1] != -1:
			ans = max(ans, abs(a[i] - a[i + 1]))
	if max_n == minf:
		print(0, 0)
	else:
		x = (max_n + min_n) // 2
		print(max(max_n - x, x - min_n, ans), x)


import math
import sys
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	e = 0
	c = 0
	r = []
	mx = -10
	mn = 10 ** 10
	for i in range(n):
		if a[i] != -1:
			if i != 0:
				if a[i - 1] == -1:
					mn = min(mn, a[i])
					mx = max(mx, a[i])
			if i != n - 1:
				if a[i + 1] == -1:
					mn = min(mn, a[i])
					mx = max(mx, a[i])
		else:
			r.append(i)
	if len(r) == n:
		k = 0
	else:
		k = (mx + mn) // 2
	for i in range(len(r)):
		a[r[i]] = k
	mx = -2
	for i in range(n - 1):
		mx = max(mx, abs(a[i] - a[i + 1]))
	print(mx, k)


k = int(input())
for o in range(k):
	n = int(input())
	arr = [int(s) for s in input().split()]
	r = []
	for i in range(n):
		if arr[i] == -1:
			if i > 0 and arr[i - 1] != -1:
				r.append(arr[i - 1])
			if i < n - 1 and arr[i + 1] != -1:
				r.append(arr[i + 1])
	r.sort()
	if len(r) != 0:
		ans = (r[0] + r[-1]) // 2
	else:
		ans = 0
	for i in range(len(arr)):
		if arr[i] == -1:
			arr[i] = ans
	m = abs(arr[0] - arr[1])
	for i in range(n - 1):
		u = abs(arr[i] - arr[i + 1])
		if m < u:
			m = u
	print(m, ans)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

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

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
input = sys.stdin.readline
res = []
for _ in range(ii()):
	n = ii()
	d = li()
	a = []
	for i in range(n):
		if d[i] == -1:
			if i > 0 and d[i - 1] != -1:
				a.append(d[i - 1])
			if i < n - 1 and d[i + 1] != -1:
				a.append(d[i + 1])
	if not a:
		res.append('0 0')
		continue
	el = (max(a) + min(a)) // 2
	new = [el if x == -1 else x for x in d]
	diff = 0
	for i in range(1, n):
		diff = max(diff, abs(new[i] - new[i - 1]))
	res.append(f'{diff} {el}')
prr(res, '\n')


from sys import stdin

def iinput():
	return int(stdin.readline())

def sinput():
	return input()

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

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	n = iinput()
	a = linput()
	missing = a.count(-1)
	if missing == n:
		print(0, 0)
	else:
		(mn, mx) = (10 ** 9, 0)
		for i in range(n):
			if a[i] == -1:
				if i > 0 and a[i - 1] != -1:
					mn = min(mn, a[i - 1])
					mx = max(mx, a[i - 1])
				if i < n - 1 and a[i + 1] != -1:
					mn = min(mn, a[i + 1])
					mx = max(mx, a[i + 1])
		k = (mn + mx) // 2
		mxd = 0
		for i in range(n):
			if a[i] == -1:
				a[i] = k
			if i > 0:
				mxd = max(mxd, abs(a[i] - a[i - 1]))
		print(mxd, k)


import os
from io import BytesIO, IOBase
import sys
import math
from math import ceil
from collections import Counter

def main():
	for t in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		if a.count(-1) == n:
			print(0, 0)
		else:
			b = []
			if a[0] == -1 and a[1] != -1 or (a[0] != -1 and a[1] == -1):
				b.append(a[1] if a[1] != -1 else a[0])
			if a[-1] == -1 and a[-2] != -1 or (a[-2] == -1 and a[-1] != -1):
				b.append(a[-2] if a[-2] != -1 else a[-1])
			for i in range(1, n - 1):
				if a[i] != -1:
					if a[i + 1] == -1 or a[i - 1] == -1:
						b.append(a[i])
			k = (max(b) + min(b)) // 2
			m = abs(k - max(b, key=lambda x: abs(x - k)))
			for i in range(n - 1):
				if a[i] != -1 and a[i + 1] != -1:
					m = max(m, abs(a[i] - a[i + 1]))
			print(m, k)
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 _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	maa = 0
	if a[0] != -1 and a[1] == -1:
		b.append(a[0])
	if a[-1] != -1 and a[-2] == -1:
		b.append(a[-1])
	for i in range(1, n - 1):
		if a[i] != -1 and (a[i - 1] == -1 or a[i + 1] == -1):
			b.append(a[i])
	for i in range(1, n):
		if a[i - 1] != -1 and a[i] != -1:
			maa = max(maa, abs(a[i] - a[i - 1]))
	if b == []:
		print(0, 0)
		continue
	ma = max(b)
	mi = min(b)
	k = (ma + mi) // 2
	m = max(abs(ma - k), abs(mi - k))
	print(max(m, maa), k)


from math import ceil
t = int(input())

def test(mid):
	m = 0
	for i in range(len(nums) - 1):
		(p, p1) = (nums[i] if i not in rep else mid, nums[i + 1] if i + 1 not in rep else mid)
		if abs(p1 - p) > m:
			m = abs(p1 - p)
	return m
for i in range(t):
	n = int(input())
	nums = list(map(int, input().split()))
	ma = -1
	mi = 9999999999
	for i in range(len(nums) - 1):
		(p, p1) = (nums[i], nums[i + 1])
		if p == -1 and p1 == -1:
			continue
		elif p == -1:
			if nums[i + 1] < mi:
				mi = nums[i + 1]
			if nums[i + 1] > ma:
				ma = nums[i + 1]
		elif p1 == -1:
			if nums[i] < mi:
				mi = nums[i]
			if nums[i] > ma:
				ma = nums[i]
	if ma == -1 and mi == 9999999999:
		print('0 0')
	else:
		for i in range(len(nums)):
			if nums[i] == -1:
				nums[i] = (ma + mi) // 2
		res = 0
		ans = (ma + mi) // 2
		for j in range(len(nums) - 1):
			(p, p2) = (nums[j], nums[j + 1])
			if abs(p2 - p) > res:
				res = abs(p2 - p)
		print(res, ans)


import math
t = int(input())
for i in range(t):
	n = int(input())
	l = []
	li = list(map(int, input().split()))
	for k in range(n):
		if li[k] == -1:
			if k - 1 >= 0:
				if li[k - 1] != -1:
					l.append(li[k - 1])
			if k + 1 < n:
				if li[k + 1] != -1:
					l.append(li[k + 1])
	if l == []:
		ans = 0
	else:
		a = max(l)
		b = min(l)
		ans = (a + b) // 2
	for k in range(n):
		if li[k] == -1:
			li[k] = ans
	maxi = 0
	for k in range(1, n):
		if abs(li[k] - li[k - 1]) > maxi:
			maxi = abs(li[k] - li[k - 1])
	print(maxi, end=' ')
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	m = int(1000000000.0) + 1
	M = -1
	max_dif = 0
	a = list(map(int, input().split()))
	for j in range(len(a)):
		if a[j] == -1:
			if j + 1 < len(a):
				if a[j + 1] < m and a[j + 1] != -1:
					m = a[j + 1]
				if a[j + 1] > M:
					M = a[j + 1]
			if j - 1 >= 0:
				if a[j - 1] < m and a[j - 1] != -1:
					m = a[j - 1]
				if a[j - 1] > M:
					M = a[j - 1]
		else:
			if j + 1 < len(a):
				if abs(a[j] - a[j + 1]) > max_dif and a[j + 1] != -1:
					max_dif = abs(a[j] - a[j + 1])
			if j - 1 >= 0:
				if abs(a[j] - a[j - 1]) > max_dif and a[j - 1] != -1:
					max_dif = abs(a[j] - a[j - 1])
	if m == int(1000000000.0) + 1 and M == -1:
		print('0 0')
	else:
		l = max((M - m) // 2 + (M - m) % 2, max_dif)
		k = m + (M - m) // 2
		print(l, k)


t = int(input())
for test in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	mm = 0
	x = []
	for i in range(n):
		if a[i] == -1:
			if i + 1 < n and a[i + 1] != -1:
				x.append(a[i + 1])
			if i - 1 >= 0 and a[i - 1] != -1:
				x.append(a[i - 1])
		elif i + 1 < n and a[i + 1] != -1 and (abs(a[i] - a[i + 1]) > mm):
			mm = abs(a[i] - a[i + 1])
	if len(x) == 0:
		print(mm, 0)
		continue
	ss = min(x)
	ll = max(x)
	k = (ss + ll) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(n):
		if i + 1 < n and abs(a[i] - a[i + 1]) > mm:
			mm = abs(a[i] - a[i + 1])
	print(mm, k)


for _ in range(int(input())):
	n = int(input())
	lst = list(map(int, input().split()))
	if lst[0] != -1 and lst[1] == -1:
		low = lst[0]
		high = lst[0]
	else:
		low = max(lst)
		high = 0
	for i in range(1, n - 1):
		if lst[i] != -1 and (lst[i - 1] == -1 or lst[i + 1] == -1):
			if lst[i] < low:
				low = lst[i]
			if lst[i] > high:
				high = lst[i]
	if lst[n - 1] != -1 and lst[n - 2] == -1:
		if lst[n - 1] > high:
			high = lst[n - 1]
		if lst[n - 1] < low:
			low = lst[n - 1]
	ans = int((low + high) / 2)
	poss = high - ans
	for i in range(n - 1):
		if lst[i] != -1 and lst[i + 1] != -1:
			temp = abs(lst[i] - lst[i + 1])
			if temp > poss:
				poss = temp
	print(poss, ans)


t = int(input())
INF = 1000000007
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	am = []
	m2 = -INF
	for i in range(1, n):
		if (a[i] == -1) ^ (a[i - 1] == -1):
			am.append(max(a[i], a[i - 1]))
		elif a[i] != -1 and a[i - 1] != -1:
			m2 = max(abs(a[i - 1] - a[i]), m2)
	if len(am) == 0:
		am.append(0)
	k = (max(am) + min(am)) // 2
	m = abs(max(am) - k)
	m = max(m, m2)
	print(m, k)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

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

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
t = INT()
while t != 0:
	n = INT()
	a = LIST()
	foo = set()
	mx = 0
	mn = INF
	for i in range(n):
		if a[i] == -1:
			if i == 0:
				if a[i + 1] == -1:
					continue
				else:
					foo.add(a[i + 1])
			elif i == n - 1:
				if a[i - 1] == -1:
					continue
				else:
					foo.add(a[i - 1])
			else:
				if a[i + 1] != -1:
					foo.add(a[i + 1])
				if a[i - 1] != -1:
					foo.add(a[i - 1])
	if len(foo) != 0:
		mx = max(foo)
		mn = min(foo)
		k = (mx + mn) // 2
	else:
		k = 0
	overall = 0
	for j in range(n):
		if a[j] == -1:
			a[j] = k
	for j in range(1, n):
		overall = max(overall, abs(a[j] - a[j - 1]))
	print(overall, k)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	L = [int(x) for x in input().strip().split(' ')]
	(mini, maxi) = (float('inf'), 0)
	for i in range(n):
		if L[i] == -1:
			if i > 0 and L[i - 1] != -1:
				mini = min(mini, L[i - 1])
				maxi = max(maxi, L[i - 1])
			if i < n - 1 and L[i + 1] != -1:
				mini = min(mini, L[i + 1])
				maxi = max(maxi, L[i + 1])
	if mini == float('inf'):
		mini = 0
	k = (maxi + mini) // 2
	L = [k if x == -1 else x for x in L]
	m = 0
	for i in range(1, n):
		m = max(m, abs(L[i] - L[i - 1]))
	print(m, k)


t = int(input())
for o in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m1 = max(a) + 1
	m2 = 0
	for i in range(n):
		if a[i] != -1:
			if i + 1 < n:
				if a[i + 1] == -1:
					if a[i] < m1:
						m1 = a[i]
					if a[i] > m2:
						m2 = a[i]
			if i - 1 >= 0:
				if a[i - 1] == -1:
					if a[i] < m1:
						m1 = a[i]
					if a[i] > m2:
						m2 = a[i]
	k = (m1 + m2) // 2
	m = 0
	if a[0] == -1:
		a[0] = k
	for i in range(1, n):
		if a[i] == -1:
			a[i] = k
		m = max(m, abs(a[i] - a[i - 1]))
	print(m, k)


from math import floor, ceil
t = int(input())
for _ in range(0, t):
	n = int(input())
	aa = [int(i) for i in input().split()]
	problem = []
	already = []
	for i in range(0, n - 1):
		if aa[i] == -1 and aa[i + 1] != -1:
			problem.append(aa[i + 1])
		elif aa[i] != -1 and aa[i + 1] == -1:
			problem.append(aa[i])
		elif aa[i] != -1 and aa[i + 1] != -1:
			already.append(abs(aa[i] - aa[i + 1]))
	if len(problem) == 0:
		print(0, 0)
	else:
		problem.sort()
		k = (problem[-1] + problem[0]) // 2
		also = -1
		original = max(problem[-1] - k, k - problem[0])
		if len(already):
			also = max(already)
		if also != -1:
			if original <= also:
				print(also, k)
			else:
				print(original, k)
		else:
			print(original, k)


for t in range(int(input())):
	n = int(input())
	a = map(int, input().split())
	a = list(a)
	start = -1
	flag = False
	elems = []
	for i in range(1, n - 1):
		if a[i] != -1 and (a[i - 1] == -1 or a[i + 1] == -1):
			elems.append(a[i])
	if len(a) > 0 and a[1] == -1 and (a[0] != -1):
		elems.append(a[0])
	if len(a) > 1 and a[-2] == -1 and (a[-1] != -1):
		elems.append(a[-1])
	if len(elems) == 0:
		if max(a) == -1:
			print('0 0')
		else:
			print('0', max(a))
		continue
	k = (max(elems) + min(elems)) // 2
	maxd = 0
	for i in range(n - 1):
		if a[i] + a[i + 1] == -2:
			diff = 0
		elif a[i] == -1:
			diff = abs(k - a[i + 1])
		elif a[i + 1] == -1:
			diff = abs(k - a[i])
		else:
			diff = abs(a[i] - a[i + 1])
		maxd = max(maxd, diff)
	print(maxd, k)


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	v = set()
	m = 0
	for i in range(n - 1):
		if a[i] == -1:
			if i != 0 and a[i - 1] >= 0:
				v.add(a[i - 1])
			if a[i + 1] >= 0:
				v.add(a[i + 1])
	if a[n - 1] == -1:
		if a[n - 2] >= 0:
			v.add(a[n - 2])
	if not v:
		print(0, 0)
		continue
	k = abs(max(v) + min(v)) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(n - 1):
		if abs(a[i + 1] - a[i]) > m:
			m = abs(a[i + 1] - a[i])
	print(m, k)


def solve(n, a):
	mn = float('INF')
	mx = -float('INF')
	a = [0] + a + [0]
	for (i, v) in enumerate(a):
		if v == -1 or i == 0 or i == len(a) - 1 or (a[i - 1] != -1 and a[i + 1] != -1):
			continue
		mn = min(mn, v)
		mx = max(mx, v)
	if mn == float('INF'):
		print(0, 0)
		return
	ans = (mn + mx) // 2
	f = lambda x, y: y if x == -1 else x
	a = [f(x, ans) for x in a]
	mx = -float('INF')
	for (i, v) in enumerate(a):
		if i == 0 or i >= len(a) - 2:
			continue
		mx = max(mx, abs(a[i] - a[i + 1]))
	print(mx, ans)

def main():
	tc = int(input())
	for _ in range(tc):
		n = int(input())
		a = [int(x) for x in input().split()]
		solve(n, a)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(tot, cnt) = (0, 0)
	ans = -1000000009
	(ma, mi) = (-1000000009, 1000000009)
	for i in range(n):
		if a[i] != -1:
			if i and a[i - 1] == -1 or (i + 1 < n and a[i + 1] == -1):
				tot += a[i]
				cnt += 1
			if i and a[i - 1] != -1:
				ans = max(ans, abs(a[i] - a[i - 1]))
			if i + 1 < n and a[i + 1] != -1:
				ans = max(ans, abs(a[i] - a[i + 1]))
		else:
			if i and a[i - 1] != -1:
				mi = min(mi, a[i - 1])
				ma = max(ma, a[i - 1])
			if i + 1 < n and a[i + 1] != -1:
				mi = min(mi, a[i + 1])
				ma = max(ma, a[i + 1])
	if cnt:
		tot = (ma + mi) // 2
	else:
		(tot, ma, mi) = (0, 0, 0)
	print(max(ans, ma - tot, tot - mi), tot)


for _ in range(int(input())):
	n = int(input())
	a = []
	b = []
	l = list(map(int, input().split()))
	if l.count(-1) == n:
		print(0, 0)
	else:
		for i in range(n):
			if l[i] != -1:
				if i == 0:
					if l[i + 1] == -1:
						a.append(l[i])
				elif i == n - 1:
					if l[i - 1] == -1:
						a.append(l[i])
				elif l[i + 1] == -1 or l[i - 1] == -1:
					a.append(l[i])
		k = (max(a) + min(a)) // 2
		for i in range(n):
			if l[i] == -1:
				l[i] = k
		for i in range(1, n):
			b.append(abs(l[i] - l[i - 1]))
		print(max(b), k)


import sys
import math

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

def iinput():
	return [int(x) for x in sys.stdin.readline().split()]

def main():
	n = int(input())
	data = iinput()
	razn = 0
	(maxx, minn) = (-1, 10 ** 9 + 1)
	for i in range(1, n):
		if data[i] == -1 and data[i - 1] != -1:
			maxx = max(maxx, data[i - 1])
			minn = min(minn, data[i - 1])
		elif data[i] != -1 and data[i - 1] == -1:
			maxx = max(maxx, data[i])
			minn = min(minn, data[i])
		elif data[i] != -1 and data[i - 1] != -1:
			razn = max(razn, abs(data[i] - data[i - 1]))
	if maxx == -1:
		print(0, 0)
	else:
		print(max(razn, (maxx - minn + 1) // 2), maxx - (maxx - minn + 1) // 2)
	return
for qwerty in range(int(input())):
	main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ma = -1
	k = []
	for j in range(len(a) - 1):
		if a[j] == -1 and a[j + 1] != -1:
			k.append(a[j + 1])
		elif a[j] != -1 and a[j + 1] == -1:
			k.append(a[j])
		else:
			ma = max(ma, abs(a[j] - a[j + 1]))
	if len(k) == 0:
		print(0, 0)
	else:
		mini = min(k)
		nmaximum = max(k)
		print(max(ma, max(k) - (mini + (nmaximum - mini) // 2)), mini + (nmaximum - mini) // 2)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def birth():
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		inamo = []
		maxdis = 0
		for i in range(n):
			if i < n - 1:
				if a[i] != -1 and a[i + 1] != -1:
					maxdis = max(maxdis, abs(a[i + 1] - a[i]))
			if a[i] == -1:
				if i == 0:
					if a[i + 1] != -1:
						if a[i + 1] not in inamo:
							inamo.append(a[i + 1])
				elif i == n - 1:
					if a[i - 1] != -1:
						if a[i - 1] not in inamo:
							inamo.append(a[i - 1])
				else:
					if a[i + 1] != -1:
						if a[i + 1] not in inamo:
							inamo.append(a[i + 1])
					if a[i - 1] != -1:
						if a[i - 1] not in inamo:
							inamo.append(a[i - 1])
		if inamo:
			res = (max(inamo) + min(inamo)) // 2
			maxlen = max(max(max(inamo) - res, res - min(inamo)), maxdis)
			yield (str(maxlen) + ' ' + str(res))
		else:
			yield '0 0'
t = int(input())
ans = birth()
print(*ans, sep='\n')


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')
testcases = int(input())
for j in range(testcases):
	n = int(input())
	val = list(map(int, input().split()))
	miny = max(val)
	maxy = min(val)
	maxsofar = 0
	for s in range(n):
		if val[s] == -1:
			if s == 0:
				if val[s + 1] != -1:
					if val[s + 1] < miny:
						miny = val[s + 1]
					if val[s + 1] > maxy:
						maxy = val[s + 1]
			elif s == n - 1:
				if val[s - 1] != -1:
					if val[s - 1] < miny:
						miny = val[s - 1]
					if val[s - 1] > maxy:
						maxy = val[s - 1]
			else:
				if val[s - 1] != -1:
					if val[s - 1] < miny:
						miny = val[s - 1]
					if val[s - 1] > maxy:
						maxy = val[s - 1]
				if val[s + 1] != -1:
					if val[s + 1] < miny:
						miny = val[s + 1]
					if val[s + 1] > maxy:
						maxy = val[s + 1]
		elif s < n - 1:
			if val[s + 1] != -1:
				diff = abs(val[s + 1] - val[s])
				if diff > maxsofar:
					maxsofar = diff
	if maxy == miny == -1:
		k = 0
		maxsofar = 0
	else:
		k = miny + (maxy - miny) // 2
		secondmax = max(abs(maxy - k), abs(miny - k))
		if secondmax > maxsofar:
			maxsofar = secondmax
	print(maxsofar, k)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	arr = []
	diff = []
	for i in range(n):
		if i == 0:
			if l[i] >= 0 and l[i + 1] == -1:
				arr.append(l[i])
		elif i == n - 1:
			if l[i] >= 0 and l[i - 1] == -1:
				arr.append(l[i])
		elif l[i] >= 0 and (l[i - 1] == -1 or l[i + 1] == -1):
			arr.append(l[i])
		if i < n - 1:
			if l[i] >= 0 and l[i + 1] >= 0:
				diff.append(abs(l[i] - l[i + 1]))
	arr.sort()
	if arr == []:
		print(0, 0)
	else:
		if diff == []:
			diff.append(0)
		if (arr[-1] - arr[0]) % 2 == 0:
			q = (arr[-1] - arr[0]) // 2
		else:
			q = (arr[-1] - arr[0]) // 2 + 1
		s = max(diff)
		print(max(s, q), (arr[-1] + arr[0]) // 2)


from itertools import permutations
import math
import sys
import queue
T = int(input())
for TT in range(0, T):
	n = int(input())
	arr = input().split(' ')
	a = []
	for i in range(0, n):
		arr[i] = int(arr[i])
	ans = 0
	for i in range(0, n):
		if arr[i] != -1:
			if i and arr[i - 1] == -1 or (i < n - 1 and arr[i + 1] == -1):
				a.append(arr[i])
			if i < n - 1 and arr[i + 1] != -1:
				ans = max(ans, abs(arr[i] - arr[i + 1]))
	L = len(a)
	if L == 0:
		print(str(ans) + ' 0')
	elif L == 1:
		print(str(ans) + ' ' + str(a[0]))
	else:
		a.sort()
		ans = max(ans, (a[L - 1] - a[0]) // 2 + (a[L - 1] - a[0]) % 2)
		print(ans, end=' ')
		print((a[L - 1] + a[0]) // 2)


for _ in range(int(input())):
	n = int(input())
	list1 = [*map(int, input().split())]
	list2 = []
	maxi = 0
	for i in range(len(list1)):
		if list1[i] == -1:
			if i > 0 and list1[i - 1] != -1:
				list2.append(list1[i - 1])
			if i < n - 1 and list1[i + 1] != -1:
				list2.append(list1[i + 1])
	if len(list2) == 0:
		s = 0
	else:
		s = (max(list2) + min(list2)) // 2
	for i in range(len(list1)):
		if list1[i] == -1:
			list1[i] = s
	for i in range(n - 1):
		maxi = max(maxi, abs(list1[i] - list1[i + 1]))
	print(maxi, s)


from sys import stdin
input = stdin.readline
for xoxo in range(1):
	for _ in range(int(input())):
		b = []
		n = int(input())
		a = [0] + list(map(int, input().split()))
		if a.count(-1) == n:
			print('0 0')
			continue
		a.append(0)
		for i in range(1, n + 1):
			if a[i] != -1:
				if a[i - 1] == -1 or a[i + 1] == -1:
					b.append(a[i])
		b = set(b)
		s = sum(b)
		ans1 = (max(b) + min(b)) // 2
		ans = []
		m1 = 0
		for j in range(2):
			ans1 += j
			m1 = 0
			for i in range(2, n + 1):
				(x, y) = (a[i], a[i - 1])
				if x == -1:
					x = ans1
				if y == -1:
					y = ans1
				m1 = max(abs(x - y), m1)
			ans.append([ans1, m1])
		if ans[0][1] <= ans[1][1]:
			print(ans[0][1], ans[0][0])
		else:
			print(ans[1][1], ans[1][0])


import sys
from math import *
input = sys.stdin.buffer.readline
t = int(input())
while t:
	t -= 1
	n = int(input())
	arr = list(map(int, input().split()))
	(s, count, dif) = [0] * 3
	for i in range(n - 1):
		if arr[i] == -1 or arr[i + 1] == -1:
			continue
		elif dif < int(fabs(arr[i + 1] - arr[i])):
			dif = int(fabs(arr[i + 1] - arr[i]))
	c = 1
	narr = []
	for i in range(n):
		if arr[i] == -1:
			c = 0
		elif c == 0:
			narr.append(arr[i])
			c = 1
		elif i + 1 != n and arr[i + 1] == -1:
			narr.append(arr[i])
		else:
			continue
	if len(narr) == 0:
		print('0 0')
	else:
		mini = min(narr)
		maxm = max(narr)
		c = (mini + maxm) // 2
		print(max(dif, maxm - c, c - mini), c)


from math import ceil, inf
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	(prom, cnt) = (0, 0)
	s = set()
	glob = 0
	for i in range(n - 1):
		if a[i] == -1 and a[i + 1] != -1:
			s.add(a[i + 1])
		if a[i] != -1 and a[i + 1] == -1:
			s.add(a[i])
		if a[i] != -1 and a[i + 1] != -1:
			glob = max(glob, abs(a[i + 1] - a[i]))
	if not s:
		print(0, 0)
	else:
		(M, m) = (max(s), min(s))
		k = int((M + m) / 2)
		print(max([glob, M - k, m - k]), k)


import math
for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	mean = []
	visited = [0] * n
	for i in range(n):
		if arr[i] == -1:
			if i == 0 or i == n - 1:
				if i == 0:
					if arr[i + 1] >= 0 and visited[i + 1] == 0:
						mean.append(arr[i + 1])
						visited[i + 1] = 1
				elif arr[i - 1] >= 0 and visited[i - 1] == 0:
					mean.append(arr[i - 1])
					visited[i - 1] = 1
			else:
				if arr[i + 1] >= 0 and visited[i + 1] == 0:
					mean.append(arr[i + 1])
					visited[i + 1] = 1
				if arr[i - 1] >= 0 and visited[i - 1] == 0:
					mean.append(arr[i - 1])
					visited[i - 1] = 1
	max_diff = 0
	for i in range(n - 1):
		if arr[i] >= 0 and arr[i + 1] >= 0:
			max_diff = max(max_diff, abs(arr[i] - arr[i + 1]))
	if len(mean) == 0:
		print(max_diff, 0)
	else:
		km = (max(mean) + min(mean)) // 2
		t1 = 0
		for i in range(n):
			if arr[i] == -1:
				arr[i] = km
		for i in range(n - 1):
			t1 = max(t1, abs(arr[i] - arr[i + 1]))
		print(t1, km)


t = int(input())
for i in range(t):
	n = int(input())
	data = list(map(int, input().strip().split()))
	arr = []
	for j in range(len(data)):
		if data[j] != -1 and (j - 1 >= 0 and data[j - 1] == -1 or (j + 1 < len(data) and data[j + 1] == -1)):
			arr.append(data[j])
	arr.sort()
	if len(arr) == 0:
		x = 0
	else:
		x = (arr[-1] + arr[0]) // 2
	ans = 0
	for j in range(len(data)):
		if data[j] == -1:
			data[j] = x
		if j >= 1:
			ans = max(abs(data[j] - data[j - 1]), ans)
	print('%d %d' % (ans, x))


t = int(input())
for i in range(t):
	n = int(input())
	mx = 0
	mn = 10000000000
	ar = [int(x) for x in input().split()]
	for j in range(n):
		if ar[j] == -1:
			if j == 0:
				if ar[j + 1] != -1:
					mx = max(mx, ar[j + 1])
					mn = min(mn, ar[j + 1])
			elif j == n - 1:
				if ar[j - 1] != -1:
					mx = max(mx, ar[j - 1])
					mn = min(mn, ar[j - 1])
			else:
				if ar[j - 1] != -1:
					mx = max(mx, ar[j - 1])
					mn = min(mn, ar[j - 1])
				if ar[j + 1] != -1:
					mx = max(mx, ar[j + 1])
					mn = min(mn, ar[j + 1])
	if mn == 10000000000:
		mn = 0
	k = (mn + mx) // 2
	for j in range(n):
		if ar[j] == -1:
			ar[j] = k
	md = 0
	for j in range(n - 1):
		md = max(md, abs(ar[j] - ar[j + 1]))
	print(md, k, sep=' ')


for _ in range(int(input())):
	n = int(input())
	ls = [int(x) for x in input().split()]
	if ls.count(-1) == n:
		print(0, 0)
	else:
		m1 = 1000000000.0
		m2 = -10
		for i in range(n):
			if i != n - 1 and ls[i + 1] == -1 and (ls[i] != -1):
				m1 = min(m1, ls[i])
				m2 = max(ls[i], m2)
			if i != 0 and ls[i - 1] == -1 and (ls[i] != -1):
				m1 = min(m1, ls[i])
				m2 = max(m2, ls[i])
		rep = (m1 + m2) // 2
		for i in range(n):
			if ls[i] == -1:
				ls[i] = rep
		ans = -1000000000.0
		for i in range(n - 1):
			ans = max(ans, abs(ls[i + 1] - ls[i]))
		print(ans, rep)


n = int(input())
for v in range(n):
	l = int(input())
	a = list(map(int, input().split()))
	t = []
	for i in range(l):
		if a[i] != -1:
			if i > 0 and a[i - 1] == -1 or (i < l - 1 and a[i + 1] == -1):
				t.append(a[i])
	if not t:
		print(0, 0)
	else:
		mi = min(t)
		ma = max(t)
		k = (mi + ma) // 2
		max_diff = 0
		for e in range(l - 1):
			if a[e] == -1:
				a[e] = k
			if a[e + 1] == -1:
				a[e + 1] = k
			max_diff = max(max_diff, abs(a[e] - a[e + 1]))
		print(max_diff, k)


for _ in range(int(input())):
	n = int(input())
	ans = 0
	adj = []
	a = tuple(map(int, input().split()))
	a1 = iter(a)
	next(a1)
	for (ai, aj) in zip(a, a1):
		if ai > -1 < aj:
			ans = max(ans, abs(ai - aj))
		elif ai != aj:
			adj.append(ai + aj + 1)
	(min_adj, max_adj) = (min(adj), max(adj)) if adj else (0, 0)
	print(max(ans, (max_adj - min_adj + 1) // 2), (min_adj + max_adj) // 2)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = []
	for i in range(n):
		if a[i] == -1:
			if i - 1 >= 0 and a[i - 1] != -1:
				d.append(a[i - 1])
			if i + 1 < n and a[i + 1] != -1:
				d.append(a[i + 1])
	rep = 0
	if d:
		rep = (min(d) + max(d)) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = rep
	maxi = -1
	for i in range(1, n):
		maxi = max(maxi, abs(a[i] - a[i - 1]))
	print(maxi, rep)


def solve(n, arr):
	max_e = -1
	min_e = 10 ** 9
	max_d = 0
	for i in range(n):
		if arr[i] == -1:
			continue
		if i > 0 and arr[i - 1] == -1 or (i < n - 1 and arr[i + 1] == -1):
			max_e = max(max_e, arr[i])
			min_e = min(min_e, arr[i])
	for i in range(n - 1):
		if arr[i] != -1 and arr[i + 1] != -1:
			max_d = max(max_d, abs(arr[i + 1] - arr[i]))
	if max_e == -1:
		min_e = max_e = 0
	k = (max_e + min_e) // 2
	m = max(max_d, (max_e - min_e + 1) // 2)
	return (m, k)

def main():
	t = int(input())
	for i in range(t):
		(m, k) = solve(int(input()), [int(e) for e in input().split()])
		print(m, k)
main()


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	ele = []
	if arr[0] == -1:
		if arr[1] != -1:
			ele.append(arr[1])
	if arr[-1] == -1:
		if arr[-2] != -1:
			ele.append(arr[-2])
	for i in range(1, len(arr) - 1):
		if arr[i] == -1:
			if arr[i + 1] != -1:
				ele.append(arr[i + 1])
			if arr[i - 1] != -1:
				ele.append(arr[i - 1])
	ans = -1
	for i in range(len(arr) - 1):
		if arr[i] != -1:
			if arr[i + 1] != -1:
				ans = max(ans, abs(arr[i] - arr[i + 1]))
	if len(ele) == 0:
		print(0, 0)
		continue
	else:
		mx = max(ele)
		mn = min(ele)
		k = (mx + mn) // 2
		ans = max(abs(mn - k), abs(mx - k), ans)
		print(ans, k)


import collections, heapq

def solution():
	n = int(input().strip())
	a = [int(x) for x in input().strip().split(' ')]
	known = float('-inf')
	(m, M) = (float('inf'), float('-inf'))
	for i in range(len(a) - 1):
		if a[i] == -1:
			if a[i + 1] != -1:
				m = min(m, a[i + 1])
				M = max(M, a[i + 1])
		elif a[i + 1] == -1:
			m = min(m, a[i])
			M = max(M, a[i])
		else:
			known = max(known, abs(a[i] - a[i + 1]))
	if m == float('inf'):
		if known == float('-inf'):
			diff = 0
			k = 0
		else:
			diff = known
			k = 0
	else:
		k = (m + M) // 2
		diff = max(known, abs(k - m), abs(k - M))
	print(diff, k)

def main():
	T = int(input().strip())
	for _ in range(T):
		solution()
main()


for _ in range(int(input())):
	x = int(input())
	y = list(map(int, input().split()))
	flag = 0
	m1min = 10 ** 9 + 1
	m2max = -1
	for i in range(x):
		if y[i] < m1min:
			m1min = y[i]
		if y[i] != -1:
			m2max = y[i]
	MAX = -1
	if m2max == -1:
		print(0, 0)
		continue
	m1min = 10 ** 9 + 1
	m2max = -1
	MAX = -1
	for i in range(x - 1):
		if y[i] != -1 and y[i + 1] != -1:
			if MAX < abs(y[i] - y[i + 1]):
				MAX = abs(y[i] - y[i + 1])
		if y[i] != -1 and y[i + 1] == -1:
			if m2max < y[i]:
				m2max = y[i]
			if m1min > y[i]:
				m1min = y[i]
		if y[i] == -1 and y[i + 1] != -1:
			if m1min > y[i + 1]:
				m1min = y[i + 1]
			if m2max < y[i + 1]:
				m2max = y[i + 1]
	temp = (m2max + m1min) // 2
	if MAX == -1:
		print(m2max - temp, temp)
	elif MAX >= m2max - temp:
		print(MAX, temp)
	else:
		print(m2max - temp, temp)


import sys
from collections import deque
input = sys.stdin.readline
t = int(input())
out = []
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt_unk = 0
	l = -1
	for v in a:
		if v == -1:
			cnt_unk += 1
		else:
			if l == -1:
				l = v
			r = v
	if cnt_unk == n:
		out.append('0 0')
		continue
	d = deque(a)
	d.appendleft(l)
	d.append(r)
	min_ = 10 ** 10
	max_ = 0
	for i in range(1, len(d) - 1):
		if d[i] == -1:
			for v in [d[i - 1], d[i + 1]]:
				if v != -1:
					max_ = max(max_, v)
					min_ = min(min_, v)
	res = (max_ + min_) // 2
	for i in range(1, len(d) - 1):
		if d[i] == -1:
			d[i] = res
	ans = [0, res]
	for i in range(len(d) - 1):
		sa = abs(d[i] - d[i + 1])
		if sa > ans[0]:
			ans[0] = sa
	out.append('{} {}'.format(ans[0], ans[1]))
print('\n'.join(out))


dbg = False
tc = 581
rc = 0
k = int(input())
for __ in range(k):
	n = int(input())
	xm = -1
	xM = -1
	e = True
	predif = -1
	a = [int(x) if x != '-1' else None for x in input().split()]
	if dbg and k == 10000:
		rc += 1
		if rc == tc:
			print(a)
			break
		else:
			continue
	for i in range(n):
		if a[i] != None:
			e = False
			if i != 0:
				if a[i - 1] != None:
					predif = max(predif, abs(a[i - 1] - a[i]))
			if i != n - 1:
				if a[i + 1] != None:
					predif = max(predif, abs(a[i + 1] - a[i]))
	if e:
		print(0, 0)
		continue
	for i in range(n):
		if a[i] == None:
			if i != 0:
				if a[i - 1] != None:
					xm = a[i - 1] if xm == -1 else min(xm, a[i - 1])
					xM = a[i - 1] if xM == -1 else max(xM, a[i - 1])
			if i != n - 1:
				if a[i + 1] != None:
					xm = a[i + 1] if xm == -1 else min(xm, a[i + 1])
					xM = a[i + 1] if xM == -1 else max(xM, a[i + 1])
	val = (xM + xm) // 2
	ans = max(xm - val, xM - val)
	if dbg:
		print(xm, xM)
	print(ans, val) if ans >= predif else print(predif, val)


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	minVal = float('inf')
	maxVal = -float('inf')
	for (i, val) in enumerate(a):
		if val >= 0 and (i > 0 and a[i - 1] < 0 or (i < n - 1 and a[i + 1] < 0)):
			minVal = min(minVal, val)
			maxVal = max(maxVal, val)
	if minVal == float('inf'):
		print(0, 0)
		continue
	k = maxVal + minVal >> 1
	if a[0] < 0:
		a[0] = k
	maxDelta = 0
	for i in range(1, n):
		if a[i] < 0:
			a[i] = k
		maxDelta = max(maxDelta, abs(a[i] - a[i - 1]))
	print(maxDelta, k)


t = int(input())
for _ in range(t):
	a = int(input())
	h = list(map(int, input().split()))
	mi = 1000000000.0 + 1
	ma = 0
	ans = 0
	f = 0
	if a > 2:
		for i in range(1, a - 1):
			if h[i - 1] == -1 and h[i] != -1:
				mi = min(h[i], mi)
				ma = max(h[i], ma)
				f = 1
			elif h[i - 1] != -1 and h[i] == -1:
				mi = min(h[i - 1], mi)
				ma = max(h[i - 1], ma)
				f = 1
			else:
				ans = max(ans, abs(h[i - 1] - h[i]))
			if h[i + 1] == -1 and h[i] != -1:
				mi = min(h[i], mi)
				ma = max(h[i], ma)
				f = 1
			elif h[i + 1] != -1 and h[i] == -1:
				mi = min(h[i + 1], mi)
				ma = max(h[i + 1], ma)
				f = 1
			else:
				ans = max(ans, abs(h[i + 1] - h[i]))
	elif h[0] == -1 and h[1] != -1:
		mi = min(h[1], mi)
		ma = max(h[1], ma)
		f = 1
	elif h[0] != -1 and h[1] == -1:
		mi = min(h[0], mi)
		ma = max(h[0], ma)
		f = 1
	else:
		ans = max(ans, abs(h[0] - h[1]))
	if f == 1:
		print(max(ans, ma - (ma + mi) // 2), (ma + mi) // 2)
	else:
		print(0, 0)


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	N = int(readline())
	A = list(map(int, readline().split()))
	res = 0
	candi = []
	for i in range(N - 1):
		if A[i] >= 0 and A[i + 1] >= 0:
			res = max(res, abs(A[i + 1] - A[i]))
		if A[i] == -1 and A[i + 1] >= 0:
			candi.append(A[i + 1])
	for i in range(1, N):
		if A[i] == -1 and A[i - 1] >= 0:
			candi.append(A[i - 1])
	if candi:
		mini = min(candi)
		maxi = max(candi)
		med = (mini + maxi) // 2
		m = max(maxi - med, med - mini, res)
		k = med
	else:
		m = res
		k = 0
	Ans[qu] = (m, k)
print('\n'.join([f'{m} {k}' for (m, k) in Ans]))


n = int(input())
answer = []
for i in range(n):
	length = int(input())
	lis = list(map(int, input().split()))
	max_2 = 0
	sor = []
	for j in range(length):
		if lis[j] == -1:
			if j != 0 and lis[j - 1] != -1:
				sor.append(lis[j - 1])
			if j != length - 1 and lis[j + 1] != -1:
				sor.append(lis[j + 1])
	sor.sort()
	if len(sor) > 0:
		max_1 = int((sor[0] + sor[-1]) / 2)
	else:
		max_1 = 0
	for j in range(length):
		if lis[j] == -1:
			lis[j] = max_1
	for j in range(length - 1):
		max_2 = max(max_2, abs(lis[j] - lis[j + 1]))
	print(max_2, max_1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	s = []
	for i in range(n):
		if i > 0 and a[i - 1] == -1 and (a[i] != -1):
			s.append(a[i])
		elif i < n - 1 and a[i + 1] == -1 and (a[i] != -1):
			s.append(a[i])
	s.sort()
	if len(s) == 0:
		print(0, 0)
		continue
	k = (s[0] + s[-1]) // 2
	m = -1
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(n - 1):
		m = max(abs(a[i] - a[i + 1]), m)
	print(m, k)


t = int(input())
for _ in range(t):
	n = int(input())
	al = list(map(int, input().split()))
	bl = []
	for i in range(n - 1):
		if al[i] == -1 and al[i + 1] != -1:
			bl.append(al[i + 1])
		elif al[i] != -1 and al[i + 1] == -1:
			bl.append(al[i])
	bl = sorted(bl)
	if len(bl) == 0:
		print(0, 0)
		continue
	ans = (bl[0] + bl[-1]) // 2
	ans2 = 0
	for i in range(n - 1):
		if al[i] == -1:
			al[i] = ans
		if al[i + 1] == -1:
			al[i + 1] = ans
		k = abs(al[i + 1] - al[i])
		ans2 = max(ans2, k)
	print(ans2, ans)


import sys
input = sys.stdin.readline
t = int(input())
for test in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	MAX = 0
	DIFMIN = 10 ** 10
	DIFMAX = -100
	for i in range(1, n):
		if A[i - 1] == A[i] == -1:
			continue
		elif A[i - 1] == -1:
			DIFMIN = min(DIFMIN, A[i])
			DIFMAX = max(DIFMAX, A[i])
		elif A[i] == -1:
			DIFMIN = min(DIFMIN, A[i - 1])
			DIFMAX = max(DIFMAX, A[i - 1])
		else:
			MAX = max(MAX, abs(A[i] - A[i - 1]))
	if DIFMIN == 10 ** 10:
		print(0, 0)
	else:
		k = (DIFMAX + DIFMIN) // 2
		m = max(MAX, DIFMAX - k, k - DIFMIN)
		print(m, k)


def solve():
	x = int(input())
	s = list(map(int, input().split()))
	z = []
	for n in range(x):
		if s[n] != -1:
			if n > 0 and n < x - 1:
				if s[n - 1] == -1 or s[n + 1] == -1:
					z.append(s[n])
			elif n == 0:
				if s[1] == -1:
					z.append(s[0])
			elif s[-2] == -1:
				z.append(s[-1])
	z.sort()
	if len(z) == 0:
		print(0, 0)
		return
	res = (z[0] + z[-1]) // 2
	ans = 0
	for n in range(1, x):
		if s[n] == -1:
			s[n] = res
		if s[n - 1] == -1:
			s[n - 1] = res
		ans = max(ans, abs(s[n] - s[n - 1]))
	print(ans, res)
for n in range(int(input())):
	solve()


import sys
t = int(sys.stdin.readline().rstrip())

def main():
	for _ in range(t):
		n = int(sys.stdin.readline().rstrip())
		(*a,) = map(int, sys.stdin.readline().split())
		m = 0
		res = set()
		for i in range(n):
			cur = a[i]
			if cur == -1:
				if i > 0 and a[i - 1] != -1:
					res.add(a[i - 1])
				if i < n - 1 and a[i + 1] != -1:
					res.add(a[i + 1])
			elif i > 0 and a[i - 1] != -1:
				m = max(m, abs(cur - a[i - 1]))
		res = sorted(res)
		if not res:
			k = 0
		else:
			k = (res[0] + res[-1]) // 2
			m = max(res[-1] - k, m)
		yield (m, k)
ans = main()
for a in ans:
	print(*a, sep=' ')


import sys
import math
input = sys.stdin.readline
q = int(input())

def sol(arr, mm):
	z = [a if a != -1 else mm for a in arr]
	maxdiff = 0
	for i in range(len(z) - 1):
		diff = abs(z[i] - z[i + 1])
		maxdiff = max(maxdiff, diff)
	return maxdiff
for _ in range(q):
	n = int(input())
	x = [int(_) for _ in input().split()]
	nums = list()
	for i in range(len(x) - 1):
		if (x[i] == -1) != (x[i + 1] == -1):
			nums.append(x[i] * x[i + 1] * -1)
	if not nums:
		mean = 0
	else:
		mean = max(nums) / 2 + min(nums) / 2
	asol = math.ceil(mean)
	bsol = math.floor(mean)
	axax = sol(x, asol)
	bxbx = sol(x, bsol)
	if axax < bxbx:
		print(axax, asol)
	else:
		print(bxbx, bsol)


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

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

def S():
	return input()

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

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

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

def input():
	return sys.stdin.readline().rstrip()

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False

def solve(T):
	n = I()
	a = LI()
	maxv = 0
	minv = 10 ** 19
	missing_count = 0
	if n == 2:
		if a[0] == -1 and a[1] != -1:
			print(0, a[1])
		elif a[0] != -1 and a[1] == -1:
			print(0, a[0])
		else:
			print(0, 0)
		return
	for i in range(1, n - 1):
		if a[i - 1] == -1 and a[i] != -1:
			maxv = max(maxv, a[i])
			minv = min(minv, a[i])
		if a[i - 1] != -1 and a[i] == -1:
			maxv = max(maxv, a[i - 1])
			minv = min(minv, a[i - 1])
		if a[i] != -1 and a[i + 1] == -1:
			maxv = max(maxv, a[i])
			minv = min(minv, a[i])
		if a[i] == -1 and a[i + 1] != -1:
			maxv = max(maxv, a[i + 1])
			minv = min(minv, a[i + 1])
		if a[i] == -1:
			missing_count += 1
	if a[0] == -1:
		missing_count += 1
	if a[-1] == -1:
		missing_count += 1
	if missing_count == n:
		print(0, 0)
		return
	k = (minv + maxv) // 2
	a = [i if i != -1 else k for i in a]
	diff = 0
	for i in range(n - 1):
		diff = max(diff, abs(a[i] - a[i + 1]))
	if missing_count == 0:
		print(diff, 0)
	else:
		print(diff, k)

def main():
	T = I()
	for i in range(T):
		solve(T)
main()


from sys import stdin, stdout
input = stdin.buffer.readline
t = int(input())

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	diff = maxval = 0
	minval = 10 ** 9
	allneg = True
	for i in range(n):
		if arr[i] >= 0:
			allneg = False
		if arr[i] == -1:
			if i > 0 and arr[i - 1] >= 0:
				maxval = max(maxval, arr[i - 1])
				minval = min(minval, arr[i - 1])
			if i < n - 1 and arr[i + 1] >= 0:
				maxval = max(maxval, arr[i + 1])
				minval = min(minval, arr[i + 1])
		if i < n - 1 and arr[i] >= 0 and (arr[i + 1] >= 0):
			diff = max(diff, abs(arr[i] - arr[i + 1]))
	if allneg:
		return (0, 0)
	avg = (maxval + minval) // 2
	return (max(diff, abs(maxval - avg), abs(minval - avg)), avg)
for _ in range(t):
	(m, k) = main()
	print(m, k)


for _ in range(int(input())):
	N = int(input())
	L = list(map(int, input().split()))
	FLAG = 0
	Min = 10 ** 9 + 1
	Max = -1
	for i in range(N):
		if L[i] != -1:
			if L[i] > Max:
				Max = L[i]
			if L[i] < Min:
				Min = L[i]
	MAXIMUM = -1
	if Max == -1:
		print(0, 0)
		continue
	Min = 10 ** 9 + 1
	Max = -1
	MAXIMUM = -1
	for i in range(N - 1):
		if L[i] != -1 and L[i + 1] != -1:
			if MAXIMUM < abs(L[i] - L[i + 1]):
				MAXIMUM = abs(L[i] - L[i + 1])
		if L[i] != -1 and L[i + 1] == -1:
			if Max < L[i]:
				Max = L[i]
			if Min > L[i]:
				Min = L[i]
		if L[i] == -1 and L[i + 1] != -1:
			if Max < L[i + 1]:
				Max = L[i + 1]
			if Min > L[i + 1]:
				Min = L[i + 1]
	A = (Max + Min) // 2
	if MAXIMUM == -1:
		print(Max - A, A)
	elif MAXIMUM >= Max - A:
		print(MAXIMUM, A)
	else:
		print(Max - A, A)


for i in range(int(input())):
	n = int(input())
	a = [int(s) for s in input().split()]
	b = []
	if a[0] != -1 == a[1]:
		b.append(a[0])
	for j in range(1, n - 1):
		if a[j] != -1 and (a[j - 1] == -1 or a[j + 1] == -1):
			b.append(a[j])
	if a[-1] != -1 == a[-2]:
		b.append(a[-1])
	if len(b) == 0:
		print(0, 0)
	else:
		mi = min(b)
		ma = max(b)
		k = (mi + ma) // 2
		md = 0
		for j in range(len(a) - 1):
			md = max(md, abs((k if a[j] < 0 else a[j]) - (k if a[j + 1] < 0 else a[j + 1])))
		print(md, k)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		s = set()
		for i in range(n - 1):
			if a[i] == -1 and a[i + 1] != -1:
				s.add(i + 1)
			elif a[i] > -1 and a[i + 1] == -1:
				s.add(i)
		if len(s) == 0:
			print('0 0')
		else:
			b = [a[i] for i in s]
			k1 = (min(b) + max(b)) // 2
			k2 = (min(b) + max(b) + 1) // 2
			c = a[:]
			for (i, v) in enumerate(a):
				if v == -1:
					c[i] = k1
					a[i] = k2
			m1 = -100
			m2 = -100
			for i in range(n - 1):
				m1 = max(m1, abs(c[i] - c[i + 1]))
				m2 = max(m2, abs(a[i] - a[i + 1]))
			if m1 <= m2:
				print(m1, k1)
			else:
				print(m2, k2)
	return
main()


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
for _ in range(int(cin())):
	n = int(cin())
	lst = list(map(int, cin().split()))
	(a, b) = (0, 0)
	l = []
	if lst[0] > -1 and lst[1] < 0:
		l.append(lst[0])
	if lst[n - 1] > -1 and lst[n - 2] < 0:
		l.append(lst[n - 1])
	for i in range(1, n - 1):
		if lst[i] > -1 and (lst[i - 1] == -1 or lst[i + 1] == -1):
			l.append(lst[i])
	if not l:
		l.append(0)
	k = (max(l) + min(l)) // 2
	dif = 0
	for i in range(n):
		if lst[i] == -1:
			lst[i] = k
		if i > 0:
			dif = max(dif, max(lst[i], lst[i - 1]) - min(lst[i], lst[i - 1]))
	cout(str(dif) + ' ' + str(k) + '\n')


from math import ceil, floor, log, sqrt, factorial
inf = float('inf')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	ma = -inf
	mi = inf
	for i in range(n):
		if i > 0:
			if a[i] == -1 and a[i - 1] != -1:
				ma = max(ma, a[i - 1])
				mi = min(mi, a[i - 1])
		if i < n - 1:
			if a[i] == -1 and a[i + 1] != -1:
				ma = max(ma, a[i + 1])
				mi = min(mi, a[i + 1])
	if ma == -inf:
		ma = 0
	if mi == inf:
		mi = 0
	k = (ma + mi) // 2
	m = 0
	for i in range(n - 1):
		if a[i] == -1:
			a[i] = k
		if a[i + 1] == -1:
			a[i + 1] = k
		m = max(m, abs(a[i] - a[i + 1]))
	print(m, k)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	t1 = -1
	t2 = 100000000000
	m = 0
	for i in range(n - 1):
		if l[i] == -1 and l[i + 1] != -1:
			if l[i + 1] > t1:
				t1 = l[i + 1]
			if l[i + 1] < t2:
				t2 = l[i + 1]
		elif l[i] != -1 and l[i + 1] == -1:
			if l[i] > t1:
				t1 = l[i]
			if l[i] < t2:
				t2 = l[i]
		elif l[i] != -1 and l[i + 1] != -1:
			if abs(l[i + 1] - l[i]) > m:
				m = abs(l[i + 1] - l[i])
	if t1 == -1:
		if t2 == 100000000000:
			print(max(m, 0), 0)
		else:
			print(max(m, 0), t2)
	elif t2 == 100000000000:
		print(max(m, 0), t1)
	else:
		k = (t1 + t2) // 2
		print(max(m, t1 - k, k - t2), k)


import sys

def input():
	return sys.stdin.readline().strip()
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	dif = 0
	diffs = []
	for i in range(1, len(arr)):
		if arr[i] == -1:
			if arr[i - 1] != -1:
				diffs.append(arr[i - 1])
		elif arr[i - 1] == -1:
			diffs.append(arr[i])
		else:
			dif = max(abs(arr[i] - arr[i - 1]), dif)
	k = 0
	if len(diffs) > 0:
		mn = min(diffs)
		mx = max(diffs)
		k = mn + (mx - mn) // 2
	for diff in diffs:
		dif = max(abs(k - diff), dif)
	print(dif, k)


def solve(n, ar):
	mn = int(1000000000.0)
	mx = int(-1000000000.0)
	for i in range(n):
		if i > 0 and ar[i] == -1 and (ar[i - 1] != -1):
			mn = min(mn, ar[i - 1])
			mx = max(mx, ar[i - 1])
		if i < n - 1 and ar[i] == -1 and (ar[i + 1] != -1):
			mn = min(mn, ar[i + 1])
			mx = max(mx, ar[i + 1])
	k = (mx + mn) // 2
	m = 0
	for i in range(n):
		if ar[i] == -1:
			ar[i] = k
		if i > 0:
			m = max(m, abs(ar[i] - ar[i - 1]))
	print(m, k)
t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	solve(n, ar)


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	(m1, m2) = (-1, 10 ** 9 + 1)
	for x in l:
		if x == -1:
			continue
		if x > m1:
			m1 = x
		if x < m2:
			m2 = x
	if m1 == -1 and m2 == 10 ** 9 + 1:
		print(0, 0)
		continue
	(m3, m4) = (-1, 10 ** 9 + 1)
	now = 0
	for x in range(1, n):
		if l[x - 1] == l[x] == -1:
			continue
		if l[x - 1] != -1 and l[x] != -1:
			continue
		if l[x - 1] == -1:
			now = l[x]
		else:
			now = l[x - 1]
		if m3 < now:
			m3 = now
		if m4 > now:
			m4 = now
	k = (m3 + m4) // 2
	num = 0
	for x in range(n):
		if l[x] == -1:
			l[x] = k
	for x in range(1, n):
		now = abs(l[x] - l[x - 1])
		if now > num:
			num = now
	print(num, k)


t = int(input())
from math import ceil
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	nums = []
	max_diff = 0
	for i in range(n):
		if l[i] != -1:
			if i > 0 and l[i - 1] == -1 or (i < n - 1 and l[i + 1] == -1):
				nums.append(l[i])
			if i < n - 1 and l[i + 1] != -1:
				max_diff = max(max_diff, abs(l[i] - l[i + 1]))
	diff = 0
	ans = 0
	if len(nums) != 0:
		diff = ceil((max(nums) - min(nums)) / 2)
		ans = (max(nums) + min(nums)) // 2
	max_diff = max(diff, max_diff)
	print(max_diff, ans)


t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	br = []
	for i in range(n):
		if ar[i] != -1:
			if i - 1 >= 0 and ar[i - 1] == -1:
				br.append(ar[i])
			elif i + 1 < n and ar[i + 1] == -1:
				br.append(ar[i])
	if br == []:
		print(0, 0)
		continue
	br.sort()
	k = (br[0] + br[-1]) // 2
	m = 0
	for i in range(n):
		if ar[i] == -1:
			ar[i] = k
	for i in range(1, n):
		m = max(abs(ar[i] - ar[i - 1]), m)
	print(m, k)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	dif = 0
	for i in range(n - 1):
		if a[i] != -1 and a[i + 1] != -1:
			if abs(a[i] - a[i + 1]) > dif:
				dif = abs(a[i] - a[i + 1])
	b = []
	for i in range(n):
		if i == 0:
			if a[i] != -1 and a[i + 1] == -1:
				b.append(a[i])
		elif i == n - 1:
			if a[i] != -1 and a[i - 1] == -1:
				b.append(a[i])
		elif a[i] != -1:
			if a[i - 1] == -1 or a[i + 1] == -1:
				b.append(a[i])
	b.sort()
	if len(b) != 0:
		k = (b[0] + b[len(b) - 1]) // 2
		ans = max(dif, k - b[0], b[len(b) - 1] - k)
		print(ans, k)
	else:
		print(0, 0)
	t -= 1


def main():
	import sys
	input = sys.stdin.readline
	T = int(input())
	for t in range(T):
		n = int(input())
		a = list(map(int, input().split()))
		b = []
		for i in range(n):
			if a[i] == -1:
				if i - 1 >= 0 and a[i - 1] != -1:
					b.append(a[i - 1])
				if i + 1 < n and a[i + 1] != -1:
					b.append(a[i + 1])
		if len(b) == 0:
			print(0, 0)
			continue
		(mn, mx) = (min(b), max(b))
		k = (mn + mx) // 2
		m = 0
		for i in range(n):
			if a[i] == -1:
				a[i] = k
			if i > 0:
				d = abs(a[i] - a[i - 1])
				m = max(m, d)
		print(m, k)
main()


for t in range(int(input())):
	n = int(input())
	l = [int(j) for j in input().split()]
	ls = []
	for i in range(n):
		if l[i] == -1:
			nb = [max(i - 1, 0), min(i + 1, n - 1)]
			for j in nb:
				if l[j] != -1:
					ls.append(l[j])
	lf = 1
	k = 0
	try:
		mx = max(ls)
		mn = min(ls)
		k = (mx + mn) // 2
	except:
		pass
	ans = 0
	if l[0] == -1:
		l[0] = k
	for i in range(1, n):
		if l[i] == -1:
			l[i] = k
		ans = max(ans, abs(l[i] - l[i - 1]))
	print(ans, k)


t = int(input())
for j in range(0, t):
	n = int(input())
	s = set()
	a = list(map(int, input().split()))
	for i in range(0, n - 1):
		if a[i] == -1 and a[i + 1] != -1:
			s.add(a[i + 1])
		elif a[i + 1] == -1 and a[i] != -1:
			s.add(a[i])
	if max(a) == -1:
		print(0, 0)
	else:
		aa = (max(list(s)) + min(list(s))) // 2
		for i in range(0, n):
			if a[i] == -1:
				a[i] = aa
		maxi = -1
		for i in range(1, n):
			if maxi < abs(a[i - 1] - a[i]):
				maxi = abs(a[i - 1] - a[i])
		print(maxi, aa)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	aq = [int(v) for v in sys.stdin.readline().split()]
	ma = -1
	mi = 2000000000
	f = False
	for (i, a) in enumerate(aq):
		f |= a != -1
		if i == 0:
			continue
		pa = aq[i - 1]
		if a == -1 and pa != -1:
			ma = max(ma, pa)
			mi = min(mi, pa)
		elif a != -1 and pa == -1:
			ma = max(ma, a)
			mi = min(mi, a)
	k = (ma + mi) // 2
	if not f:
		print('0 0')
		continue
	mm = -1
	la = aq[0]
	if la == -1:
		la = k
	for a in aq[1:]:
		if a == -1:
			a = k
		mm = max(mm, abs(a - la))
		la = a
	print('%s %s' % (mm, k))


def iamtefu():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		d = -1
		mn = 1000000000.0
		c = 0
		mx = 0
		for i in range(n):
			if a[i] == -1:
				if i > 0 and a[i - 1] != -1:
					mn = min(a[i - 1], mn)
					mx = max(a[i - 1], mx)
					c += 1
					d += 1
				if i < n - 1 and a[i + 1] != -1:
					mn = min(a[i + 1], mn)
					mx = max(a[i + 1], mx)
					c += 1
					d += 1
		an = (mn + mx) // 2
		if d == -1 or an < 0:
			an = 0
		for i in range(n):
			if a[i] == -1:
				a[i] = an
		m = 0
		for i in range(1, n):
			m = max(abs(a[i] - a[i - 1]), m)
		print(m, an)
iamtefu()


def program():
	n = int(input())
	l = list(map(int, input().split()))
	l2 = []
	l3 = []
	for i in range(n):
		if l[i] == -1:
			if i == 0:
				nex = l[1]
				prev = -1
			elif i == n - 1:
				nex = -1
				prev = l[n - 2]
			else:
				nex = l[i + 1]
				prev = l[i - 1]
			if nex != -1:
				l2.append(nex)
			if prev != -1:
				l2.append(prev)
		else:
			if i == 0:
				nex = l[1]
				prev = -1
			elif i == n - 1:
				nex = -1
				prev = l[n - 2]
			else:
				nex = l[i + 1]
				prev = l[i - 1]
			if nex != -1:
				l3.append(abs(l[i] - nex))
			if prev != -1:
				l3.append(abs(l[i] - prev))
	if len(l2) == 0:
		print('0 0')
		return 0
	l2 = set(l2)
	k = (max(l2) + min(l2)) // 2
	if len(l3) == 0:
		m = max(l2) - k
	else:
		m = max(max(l3), max(l2) - k)
	print(m, k)
t = int(input())
for i in range(t):
	program()


def solve(A):
	if all((a == -1 for a in A)):
		print(0, 0)
		return
	(minval, maxval) = (float('inf'), float('-inf'))
	m = float('-inf')
	for (a, b) in zip(A, A[1:]):
		if a == -1 and b >= 0:
			(minval, maxval) = (min(minval, b), max(maxval, b))
		elif b == -1 and a >= 0:
			(minval, maxval) = (min(minval, a), max(maxval, a))
		elif a >= 0 and b >= 0:
			m = max(m, abs(a - b))
	k = (minval + maxval) // 2
	m = max(m, maxval - k)
	print(m, k)

def main():
	t = int(input().strip())
	for _ in range(t):
		n = int(input().strip())
		A = [int(s) for s in input().strip().split()]
		solve(A)
main()


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
from io import BytesIO, IOBase

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

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

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
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 _ in range(ii()):
	n = ii()
	a = li()
	(m, k, md) = (0, 0, 0)
	(mn, mx) = (10 ** 10, -10 ** 10)
	for i in range(n):
		if i > 0 and a[i] == -1 and (a[i - 1] != -1):
			mn = min(mn, a[i - 1])
			mx = max(mx, a[i - 1])
		if i < n - 1 and a[i] == -1 and (a[i + 1] != -1):
			mn = min(mn, a[i + 1])
			mx = max(mx, a[i + 1])
	md = (mx + mn) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = md
		if i:
			m = max(m, abs(a[i] - a[i - 1]))
	print(m, md)


t = int(input())
for ti in range(t):
	n = int(input())
	li = [int(i) for i in input().split(' ')]
	ss = 0
	cc = 0
	sep = 0
	_min = 1919810114514
	_max = 0
	for (idx, i) in enumerate(li):
		if i == -1:
			if idx and li[idx - 1] != -1:
				_min = min(_min, li[idx - 1])
				_max = max(_max, li[idx - 1])
		else:
			if idx and li[idx - 1] != -1:
				sep = max(sep, abs(li[idx - 1] - i))
			elif idx and li[idx - 1] == -1:
				_min = min(_min, i)
				_max = max(_max, i)
			ss += i
			cc += 1
	if cc:
		r = (_min + _max) // 2
		sep = max(sep, r - _min, _max - r)
		print(sep, r)
	else:
		print(0, 0)


import sys
import math
import bisect

def main():
	for _ in range(int(input())):
		n = int(input())
		A = list(map(int, input().split()))
		B = []
		for i in range(n):
			if A[i] == -1:
				if i - 1 >= 0 and A[i - 1] != -1:
					B.append(A[i - 1])
				if i + 1 < n and A[i + 1] != -1:
					B.append(A[i + 1])
		B.sort()
		if len(B) == 0:
			k = 0
		else:
			min_val = min(B)
			max_val = max(B)
			k = (min_val + max_val) // 2
		for i in range(n):
			if A[i] == -1:
				A[i] = k
		max_delta = 0
		for i in range(n - 1):
			delta = abs(A[i + 1] - A[i])
			max_delta = max(max_delta, delta)
		print('%d %d' % (max_delta, k))
main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	num = []
	for i in range(n):
		if a[i] != -1:
			if i:
				if a[i - 1] == -1:
					num.append(a[i])
			if i != n - 1:
				if a[i + 1] == -1:
					num.append(a[i])
	if num:
		up = max(num)
		down = min(num)
		ans = (up + down) // 2
	else:
		ans = 0
	dif = 0
	for i in range(n):
		if a[i] == -1:
			a[i] = ans
		if i:
			dif = max(dif, abs(a[i] - a[i - 1]))
	print(dif, ans)


def get_k(n, arr):
	(mini, maxi) = (float('inf'), -float('inf'))
	if all([item == -1 for item in arr]):
		return (0, 0)
	for (i, item) in enumerate(arr):
		if item == -1:
			if i - 1 >= 0 and arr[i - 1] != -1:
				mini = min(arr[i - 1], mini)
				maxi = max(arr[i - 1], maxi)
			if i + 1 < n and arr[i + 1] != -1:
				mini = min(arr[i + 1], mini)
				maxi = max(arr[i + 1], maxi)
	k = (mini + maxi) // 2
	m = 0
	arr = [item if item != -1 else k for item in arr]
	i = 1
	while i < n:
		m = max(abs(arr[i] - arr[i - 1]), m)
		i += 1
	return (m, k)
T = int(input().strip())
for t in range(T):
	n = int(input().strip())
	arr = list(map(int, input().strip().split()))
	print(*get_k(n, arr))


import sys
cases = int(input())
for t in range(cases):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = []
	ans = 0
	for i in range(n):
		if a[i] != -1:
			if i > 0 and a[i - 1] == -1 or (i < n - 1 and a[i + 1] == -1):
				a1.append(a[i])
			if i < n - 1 and a[i + 1] > -1:
				ans = max(ans, abs(a[i] - a[i + 1]))
	if not a1:
		a1.append(0)
	maxv = max(a1)
	minv = min(a1)
	k = (minv + maxv) // 2
	ans = max(maxv - k, ans)
	print(ans, k)


import sys

def ceil(a, b):
	return -(-a // b)

def answer(n, a):
	mnm = -1
	lindx = -1
	nums = set()
	for i in range(n):
		if a[i] > -1 and lindx > -1:
			if lindx != i - 1:
				m = ceil(abs(a[i] - a[lindx]), 2)
			else:
				m = abs(a[i] - a[lindx])
			mnm = max(mnm, m)
			lindx = i
		elif a[i] > -1:
			lindx = i
		else:
			if i - 1 >= 0:
				nums.add(a[i - 1])
			if i + 1 <= n - 1:
				nums.add(a[i + 1])
	nums.discard(-1)
	if len(nums) == 0:
		print(0, 0)
		return
	mx = max(nums)
	mn = min(nums)
	best_k = (mx + mn) // 2
	mnm_nums = mx - best_k
	final_m = max(mnm_nums, mnm)
	print(final_m, best_k)
	return

def main():
	t = int(sys.stdin.readline())
	while t:
		n = int(sys.stdin.readline())
		a = list(map(int, sys.stdin.readline().split()))
		answer(n, a)
		t -= 1
	return
main()


k = int(input())
for i in range(k):
	n1 = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	n = max(a)
	d = 0
	for j in range(n1):
		if a[j] != -1:
			if j != 0 and a[j - 1] == -1:
				m = max(m, a[j])
				n = min(n, a[j])
			elif j != n1 - 1 and a[j + 1] == -1:
				m = max(m, a[j])
				n = min(n, a[j])
		if j > 0 and a[j] != -1 and (a[j - 1] != -1):
			d = max(d, abs(a[j] - a[j - 1]))
	s = m + n
	s = s // 2
	d = max(abs(s - m), abs(s - n), d)
	if m == n == -1:
		print(0, 0)
	else:
		print(d, s)


import sys
from math import ceil
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(int(ri())):
	n = int(ri())
	a = Ri()
	ans = []
	minn = INF
	maxx = -1
	for i in range(len(a)):
		if i - 1 >= 0 and a[i - 1] == -1 and (a[i] != -1):
			minn = min(minn, a[i])
			maxx = max(maxx, a[i])
		elif i + 1 <= n - 1 and a[i + 1] == -1 and (a[i] != -1):
			minn = min(minn, a[i])
			maxx = max(maxx, a[i])
	if minn == INF:
		print(0, 0)
	else:
		summ = (minn + maxx) // 2
		for i in range(len(a)):
			if a[i] == -1:
				a[i] = summ
		m = -1
		for i in range(1, len(a)):
			m = max(m, abs(a[i] - a[i - 1]))
		print(m, summ)


from math import inf
t = int(input())
for q in range(t):
	n = int(input())
	A = [int(i) for i in input().split()]
	mi = inf
	ma = -1 * inf
	for i in range(len(A)):
		if A[i] != -1:
			if i < len(A) - 1 and A[i + 1] == -1:
				mi = min(A[i], mi)
				ma = max(A[i], ma)
			if i > 0 and A[i - 1] == -1:
				mi = min(A[i], mi)
				ma = max(A[i], ma)
	if mi == inf:
		num = 0
	else:
		num = (mi + ma) // 2
	d = 0
	if A[0] == -1:
		A[0] = num
	for i in range(1, len(A)):
		if A[i] == -1:
			A[i] = num
		d = max(d, abs(A[i] - A[i - 1]))
	print(d, num)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	rvs = []
	ms = 0
	for i in range(0, len(a) - 1):
		if a[i] != -1 and a[i + 1] == -1:
			rvs.append(a[i])
		if a[i] == -1 and a[i + 1] != -1:
			rvs.append(a[i + 1])
	if len(rvs) == 0:
		print(0, 0)
		continue
	ls = max(rvs)
	ll = min(rvs)
	mid = (ls + ll) // 2
	a = [x if x != -1 else mid for x in a]
	for i in range(1, len(a)):
		ms = max(ms, abs(a[i] - a[i - 1]))
	print(ms, mid)