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$.

Source: codeforces | Difficulty: MEDIUM
Tags: Sorting

Greedy algorithms


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)


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

def si():
	return input()

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

def li():
	return list(mi())
import math
for i in range(ii()):
	n = ii()
	a = li()
	l = []
	for i in range(n):
		if a[i] == -1:
			if i > 0 and a[i - 1] != -1:
				l.append(a[i - 1])
			if i < n - 1 and a[i + 1] != -1:
				l.append(a[i + 1])
	if len(l) == 0:
		print(0, 100)
		continue
	mx = max(l)
	mn = min(l)
	k = (mx + mn) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	ans = -1000000000.0
	for i in range(1, n):
		ans = max(ans, abs(a[i] - a[i - 1]))
	print(ans, k)


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)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	adj = []
	for i in range(n):
		if a[i] == -1:
			if i - 1 >= 0 and a[i - 1] != -1:
				adj.append(a[i - 1])
			if i + 1 < n and a[i + 1] != -1:
				adj.append(a[i + 1])
	if len(adj) == 0:
		k = 1
		m = 0
	else:
		small = min(adj)
		large = max(adj)
		k = (small + large) // 2
		m = max(large - k, k - small)
	for i in range(1, n):
		if a[i] != -1 and a[i - 1] != -1:
			m = max(m, abs(a[i] - a[i - 1]))
	print('{} {}'.format(m, k))


import os
import operator
import sys
from io import BytesIO, IOBase

def inar():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = inar()
		lis = []
		for i in range(n):
			if arr[i] != -1:
				if i == 0:
					if arr[i + 1] == -1:
						lis.append(arr[i])
					continue
				if i == n - 1:
					if arr[i - 1] == -1:
						lis.append(arr[i])
						continue
					continue
				if arr[i - 1] == -1 or arr[i + 1] == -1:
					lis.append(arr[i])
		lis.sort()
		if len(lis) == 0:
			ans = 1
		elif len(lis) == 1:
			ans = lis[0]
		else:
			ans = (lis[0] + lis[-1]) // 2
		for i in range(n):
			if arr[i] == -1:
				arr[i] = ans
		mx = 0
		for i in range(1, n):
			mx = max(mx, abs(arr[i] - arr[i - 1]))
		print(mx, ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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


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 factorial
from collections import Counter
from heapq import heapify, heappop, heappush
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
INF = float('inf')

def main():
	N = int(input())
	for _ in range(N):
		n = int(input())
		lis = list(RL())
		le = len(lis)
		ad = set()
		res = 0
		(ma, mi) = (-float('inf'), float('inf'))
		for i in range(len(lis)):
			if lis[i] != -1:
				if i + 1 < le and lis[i + 1] != -1:
					res = max(res, abs(lis[i + 1] - lis[i]))
			if lis[i] == -1:
				if i - 1 > -1 and lis[i - 1] != -1:
					ad.add(lis[i - 1])
				if i + 1 < len(lis) and lis[i + 1] != -1:
					ad.add(lis[i + 1])
		for i in ad:
			ma = max(ma, i)
			mi = min(mi, i)
		k = (ma + mi) // 2
		res = max(res, abs(ma - k), abs(mi - k))
		if ma == -float('inf'):
			k = 10
		print(res, k)
main()


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	al = list(map(int, input().split()))
	cop = al.copy()
	(mx, mn) = (0, max(al))
	ok = False
	for i in range(n):
		if al[i] != -1:
			if i > 0 and al[i - 1] == -1 or (i < n - 1 and al[i + 1] == -1):
				mx = max(mx, al[i])
				mn = min(mn, al[i])
				ok = True
	if ok == False:
		print(0, 1)
		return
	k1 = (mx + mn) // 2 + 1
	k2 = (mx + mn) // 2
	for i in range(n):
		if al[i] == -1:
			al[i] = k1
	for i in range(n):
		if cop[i] == -1:
			cop[i] = k2
	best = best2 = 0
	for i in range(n - 1):
		best = max(best, abs(al[i] - al[i + 1]))
	for i in range(n - 1):
		best2 = max(best2, abs(cop[i] - cop[i + 1]))
	print(best if best < best2 else best2, k1 if best < best2 else k2)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


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


t = int(input())

def gag(a, k):
	ans = 0
	for x in range(len(a) - 1):
		(a1, b1) = (a[x], a[x + 1])
		if a1 == -1:
			a1 = k
		if b1 == -1:
			b1 = k
		m = abs(a1 - b1)
		if m > ans:
			ans = m
	return ans
round = lambda x: int(x + 0.5)
for x in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(l, r) = (0, 10 ** 9)
	while r - l >= 0.1:
		m = (l + r) / 2
		(q, w) = (gag(a, (l + m) / 2), gag(a, (m + r) / 2))
		if w > q:
			r = m
		else:
			l = m
	k1 = round(l)
	k2 = round(r)
	if gag(a, k1) > gag(a, k2):
		print(gag(a, k1), k1)
	else:
		print(gag(a, k2), k2)


test = int(input())
for i in range(0, test):
	a = input()
	arr = list(map(int, input().split()))
	brr = []
	for i in range(1, len(arr) - 1):
		if arr[i] == -1:
			brr.append(arr[i - 1])
			brr.append(arr[i + 1])
	if len(arr) > 1 and arr[0] == -1:
		brr.append(arr[1])
	if len(arr) > 1 and arr[len(arr) - 1] == -1:
		brr.append(arr[len(arr) - 2])
	s = set(brr)
	brr = []
	for i in s:
		if not i == -1:
			brr.append(i)
	if len(brr) == 0:
		brr.append(42)
	ans = (max(brr) + min(brr)) // 2
	crr = []
	for i in arr:
		if i == -1:
			crr.append(ans)
		else:
			crr.append(i)
	maxx = -1
	for i in range(0, len(arr) - 1):
		if abs(crr[i] - crr[i + 1]) > maxx:
			maxx = abs(crr[i] - crr[i + 1])
	print(maxx, ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = [0] + [int(i) for i in input().split()] + [0]
	delta = 0
	f = 0
	minn = 10000000000000
	maxx = -1
	prev_j = 1
	a[0] = a[1]
	a[n + 1] = a[n]
	for j in range(1, n + 1):
		if (a[j - 1] == -1 or a[j + 1] == -1) and a[j] < minn and (a[j] != -1):
			minn = a[j]
		if (a[j - 1] == -1 or a[j + 1] == -1) and a[j] > maxx:
			maxx = a[j]
		if delta < abs(a[j] - a[j - 1]) and a[j] != -1 and (a[j - 1] != -1):
			delta = abs(a[j] - a[j - 1])
	k = minn + maxx + 1 >> 1
	m = max(maxx - k, k - minn, delta)
	if maxx == -1:
		print(0, 0)
	else:
		print(m, k)


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


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


from sys import stdin, stdout, setrecursionlimit
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	mn = float('inf')
	mx = float('-inf')
	for i in range(n):
		if a[i] == -1:
			continue
		if i - 1 >= 0 and a[i - 1] == -1 or (i + 1 < n and a[i + 1] == -1):
			mx = max(mx, a[i])
			mn = min(mn, a[i])
	if mx == float('-inf'):
		print(0, 1)
		continue
	place = (mn + mx) // 2
	diff = 0
	for i in range(1, n):
		left = a[i - 1] if a[i - 1] != -1 else place
		cur = a[i] if a[i] != -1 else place
		diff = max(diff, abs(cur - left))
	print(diff, place)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if arr.count(-1) == n:
		print(0, 0)
		continue
	maximal = 0
	for i in range(n - 1):
		if arr[i] != -1 and arr[i + 1] != -1:
			maximal = max(maximal, abs(arr[i] - arr[i + 1]))
	neighs = []
	for i in range(n):
		if arr[i] != -1:
			continue
		if i != 0 and arr[i - 1] != -1:
			neighs.append(arr[i - 1])
		if i != n - 1 and arr[i + 1] != -1:
			neighs.append(arr[i + 1])
	(a, b) = (min(neighs), max(neighs))
	t = (b - a - 1) // 2 + 1
	need = a + t
	if t >= maximal:
		print(t, need)
	else:
		print(maximal, need)


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)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	cnt = 0
	u = -1
	for i in arr:
		if i != -1:
			cnt += 1
			u = i
	if cnt == 0:
		print(0, 0)
	elif cnt == 1:
		print(0, u)
	else:
		maxx = max(arr)
		m = 10 ** 10
		for i in arr:
			if i != -1:
				m = min(m, i)
		(l, h) = (m, maxx)
		temp = arr[:]
		for i in range(n):
			if temp[i] == -1:
				temp[i] = l
		t = -1
		for i in range(1, n):
			t = max(t, abs(temp[i] - temp[i - 1]))
		val1 = t
		t = -1
		temp = arr[:]
		for i in range(n):
			if temp[i] == -1:
				temp[i] = h
		for i in range(1, n):
			t = max(t, abs(temp[i] - temp[i - 1]))
		val2 = t
		while l < h:
			m = (l + h) // 2
			temp = arr[:]
			for i in range(n):
				if temp[i] == -1:
					temp[i] = m
			t = -1
			for i in range(1, n):
				t = max(t, abs(temp[i] - temp[i - 1]))
			if val1 > val2:
				l = m
				val1 = t
			else:
				h = m
				val2 = t
			if abs(h - l) == 1:
				break
		if val1 < val2:
			print(val1, l)
		else:
			print(val2, h)


I = input
for _ in [0] * int(I()):
	I()
	a = [*map(int, I().split())]
	b = [y for (x, y, z) in zip([0] + a, a, a[1:] + [0]) if -1 == x | z < y] or [0]
	l = min(b)
	m = max([(max(b) - l + 1) // 2] + [abs(x - y) for (x, y) in zip(a, a[1:]) if x | y > 0])
	print(m, l + m)


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)


import math
for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	d = 999999988888
	e = -1
	z = 0
	if n == 1:
		print(0, 1)
	else:
		for i in range(n - 1):
			if li[i] == -1:
				if li[i + 1] != -1:
					d = min(d, li[i + 1])
					e = max(e, li[i + 1])
			elif li[i + 1] != -1:
				z = max(abs(li[i + 1] - li[i]), z)
		for i in range(n - 1, 0, -1):
			if li[i] == -1:
				if li[i - 1] != -1:
					d = min(d, li[i - 1])
					e = max(e, li[i - 1])
			elif li[i - 1] != -1:
				z = max(abs(li[i - 1] - li[i]), z)
		if d == 999999988888:
			d = 12
		print(max((e - d + 1) // 2, z), (d + e) // 2)


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)


from sys import stdin
input = stdin.readline
q = int(input())
for rwere in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	parki = []
	pelne = []
	pier = -1
	ost = -1
	for i in range(n):
		if l[i] != -1:
			if pier == -1:
				pier = l[i]
			ost = l[i]
	if pier == -1:
		print(0, 69)
	else:
		l = [pier] + l + [ost]
		n += 2
		for i in range(n):
			if l[i] != -1:
				pelne.append([l[i], i])
		p = len(pelne)
		for i in range(p - 1):
			if pelne[i + 1][1] - pelne[i][1] > 1:
				ad = [pelne[i][0], pelne[i + 1][0]]
				ad.sort()
				parki.append(ad)
		le = 0
		r = 10 ** 9
		bescik = 0
		while abs(le - r) > 0:
			m = (le + r) // 2
			mini = -1000000000000000
			maksi = 1000000000000000
			for para in parki:
				mini = max(para[1] - m, mini)
				maksi = min(para[0] + m, maksi)
			if maksi >= mini:
				r = m
			else:
				le = m + 1
			bescik = (mini + maksi) // 2
		m = (le + r) // 2
		worst = 0
		for i in range(n - 1):
			if l[i] != -1 and l[i + 1] != -1:
				worst = max(worst, abs(l[i] - l[i + 1]))
		print(max(worst, m), bescik)


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)


def one():
	return int(input())

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

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

def st():
	return input()
for _ in range(one()):
	input()
	l = lis()
	m = 10 ** 9
	M = 0
	for (ind, i) in enumerate(l):
		if i == -1:
			if ind == 0:
				if l[ind + 1] == -1:
					continue
				if m > l[ind + 1]:
					m = l[ind + 1]
				if M < l[ind + 1]:
					M = l[ind + 1]
			elif ind == len(l) - 1:
				if l[ind - 1] == -1:
					continue
				if m > l[ind - 1]:
					m = l[ind - 1]
				if M < l[ind - 1]:
					M = l[ind - 1]
			else:
				if l[ind - 1] != -1:
					if m > l[ind - 1]:
						m = l[ind - 1]
					if M < l[ind - 1]:
						M = l[ind - 1]
				if l[ind + 1] != -1:
					if m > l[ind + 1]:
						m = l[ind + 1]
					if M < l[ind + 1]:
						M = l[ind + 1]
	k = (M + m) // 2
	if k == -1:
		k = 1
	maxabs = 0
	for i in range(len(l) - 1):
		if l[i] == -1:
			l[i] = k
		if l[i + 1] == -1:
			l[i + 1] = k
		if maxabs < abs(l[i] - l[i + 1]):
			maxabs = abs(l[i] - l[i + 1])
	print(maxabs, 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)


a = []

def calc(k: int):
	global a
	m = -1
	for i in range(1, len(a)):
		m = max(m, abs((k if a[i] == -1 else a[i]) - (k if a[i - 1] == -1 else a[i - 1])))
	return m
ttt = int(input())
while ttt > 0:
	ttt -= 1
	(n, a, l, r, res) = (int(input()), [int(i) for i in input().split()], 0, int(1000000000.0), (int(1000000000.0), 0))
	while r - l >= 3:
		(m1, m2) = (l + (r - l) // 3, r - (r - l) // 3)
		if calc(m1) > calc(m2):
			l = m1
		else:
			r = m2
	for i in range(l, r + 1):
		t = calc(i)
		if t < res[0]:
			res = (t, i)
	print(f'{res[0]} {res[1]}')


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


t = int(input())
while t > 0:
	n = int(input())
	a = [int(ele) for ele in input().split()]
	b = set([])
	for i in range(n):
		if a[i] == -1:
			if i == 0:
				if a[i + 1] != -1:
					b.add(a[i + 1])
			elif i > 0 and i < n - 1:
				if a[i - 1] != -1:
					b.add(a[i - 1])
				if a[i + 1] != -1:
					b.add(a[i + 1])
			elif a[i - 1] != -1:
				b.add(a[i - 1])
	if a.count(-1) == 0:
		diff = -1
		for i in range(n - 1):
			if abs(a[i] - a[i + 1]) > diff:
				diff = abs(a[i] - a[i + 1])
		print(diff, 1)
	elif len(b) == 0:
		for i in range(n):
			if a[i] == -1:
				a[i] = 1
		print(0, 1)
	else:
		mini = min(b)
		maxi = max(b)
		ele = int((mini + maxi) / 2)
		for i in range(n):
			if a[i] == -1:
				a[i] = ele
		diff = -1
		for i in range(n - 1):
			if abs(a[i] - a[i + 1]) > diff:
				diff = abs(a[i] - a[i + 1])
		print(diff, ele)
	t -= 1


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)


for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	c = a.copy()
	(ans, ans2) = (0, 0)
	a.append(-1)
	b = [0] * n
	for i in range(n):
		if a[i] == -1:
			if i:
				if a[i - 1] + 1:
					b[i - 1] = 1
			if n - i - 1:
				if a[i + 1] + 1:
					b[i + 1] = 1
	b = [a[i] for i in range(n) if b[i]]
	if not b:
		print(0, 0)
		continue
	(b, bb) = ((max(b) + min(b)) // 2, (max(b) + min(b) + 1) // 2)
	for i in range(n):
		if a[i] == -1:
			a[i] = b
			c[i] = bb
	for i in range(n - 1):
		ans = max(ans, abs(a[i] - a[i + 1]))
	for i in range(n - 1):
		ans2 = max(ans2, abs(c[i] - c[i + 1]))
	if ans > ans2:
		print(ans2, bb)
	else:
		print(ans, bb)


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)


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


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


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


import sys
import bisect
from collections import deque

def no():
	print('NO')

def dist(z, c):
	return (z[0] - c[0]) * (z[0] - c[0]) + (z[1] - c[1]) * (z[1] - c[1])

def vec(z, c):
	return z[0] * c[1] - z[1] * c[0]

def pro(z, c):
	return [z[0] - c[0], z[1] - c[1]]

def main():
	n = int(sys.stdin.readline())
	q = [int(i) for i in sys.stdin.readline().split()]
	m = 0
	w = []
	ma = 0
	mi = 1e+20
	for i in range(1, n):
		if q[i] != -1 and q[i - 1] != -1:
			m = max(abs(q[i] - q[i - 1]), m)
		elif q[i] != -1 and q[i - 1] == -1:
			ma = max(q[i], ma)
			mi = min(q[i], mi)
		elif q[i] == -1 and q[i - 1] != -1:
			ma = max(q[i - 1], ma)
			mi = min(q[i - 1], mi)
	if mi == 1e+20:
		print(0, 1)
	else:
		print(max(m, (ma - mi + 1) // 2), ma - (ma - mi + 1) // 2)
for i in range(int(sys.stdin.readline())):
	main()


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 sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(N,) = map(int, input().split())
	A = list(map(int, input().split()))
	mnx = 10 ** 9
	mxx = 0
	ms = 0
	for i in range(N):
		if A[i] == -1:
			if i != 0:
				if A[i - 1] != -1:
					mnx = min(mnx, A[i - 1])
				mxx = max(mxx, A[i - 1])
			if i != N - 1:
				if A[i + 1] != -1:
					mnx = min(mnx, A[i + 1])
				mxx = max(mxx, A[i + 1])
		elif i != N - 1 and A[i + 1] != -1:
			ms = max(ms, abs(A[i] - A[i + 1]))
	rr = (mnx + mxx) // 2
	print(max(ms, mxx - rr), rr)


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)


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

def main():
	Test = int(input())
	for t in range(Test):
		n = int(input())
		v = list(map(int, input().split()))
		mn = 10 ** 9 + 7
		mx = -1
		for i in range(n):
			if v[i] == -1:
				if i + 1 < n and v[i + 1] != -1:
					mn = min(mn, v[i + 1])
					mx = max(mx, v[i + 1])
				if i - 1 >= 0 and v[i - 1] != -1:
					mn = min(mn, v[i - 1])
					mx = max(mx, v[i - 1])
		val = (mn + mx) // 2
		for i in range(n):
			if v[i] == -1:
				v[i] = val
		ans = -1
		for i in range(n - 1):
			ans = max(ans, abs(v[i] - v[i + 1]))
		print(ans, val)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

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

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

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

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

class IOWrapper(IOBase):

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

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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)


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


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)


def mi():
	return map(int, input().split())
import math
for _ in range(int(input())):
	n = int(input())
	a = list(mi())
	s = 0
	ss = 0
	for i in a:
		if i != -1:
			s += i
			ss += 1
	if ss == 0:
		print(0, 1)
		continue
	(s, ss) = (0, 0)
	cc = []
	for i in range(n):
		if a[i] == -1:
			if i - 1 >= 0 and a[i - 1] != -1:
				cc += [a[i - 1]]
				ss += 1
			if i + 1 < n and a[i + 1] != -1:
				cc += [a[i + 1]]
				ss += 1
	ans = (min(cc) + max(cc)) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = ans
	m = 0
	for i in range(1, n):
		m = max(m, abs(a[i] - a[i - 1]))
	print(m, ans)


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


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)


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


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


t = int(input())
for ti in range(t):
	n = int(input())
	a = input().split()
	for i in range(n):
		a[i] = int(a[i])
	m = 0
	thenos = set()
	if a[0] == -1 and a[1] != -1:
		thenos.add(a[1])
	for i in range(1, n):
		if a[i] != -1 and a[i - 1] != -1:
			k = abs(a[i] - a[i - 1])
			if k > m:
				m = k
		if a[i] == -1:
			if a[i - 1] != -1:
				thenos.add(a[i - 1])
			if i < n - 1 and a[i + 1] != -1:
				thenos.add(a[i + 1])
	thenos = list(thenos)
	if len(thenos) != 0:
		maxno = max(thenos)
		minno = min(thenos)
		k = int((maxno + minno) / 2)
		maxhere = maxno - k
		if maxhere > m:
			print(maxhere, k)
		else:
			print(m, k)
	else:
		print('0 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 sys
input = sys.stdin.buffer.readline

def print(*vals):
	sys.stdout.write(' '.join(map(str, vals)) + '\n')

def prog():
	for _ in range(int(input())):
		n = int(input())
		integers = list(map(int, input().split()))
		max_diff = 0
		smallest = 10 ** 9
		largest = 0
		for i in range(n - 1):
			if integers[i] == -1 and integers[i + 1] != -1:
				smallest = min(smallest, integers[i + 1])
				largest = max(largest, integers[i + 1])
			elif integers[i + 1] == -1 and integers[i] != -1:
				largest = max(largest, integers[i])
				smallest = min(smallest, integers[i])
			else:
				max_diff = max(max_diff, abs(integers[i] - integers[i + 1]))
		best_k_diff = (largest - smallest + 1) // 2
		best_k = (largest + smallest) // 2
		if max_diff > best_k_diff:
			print(max_diff, best_k)
		else:
			print(best_k_diff, best_k)
prog()


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


from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(1000000)

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

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

def o():
	return int(input())

def r(x):
	return range(len(x))

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
MAX = float('inf')
MIN = -float('inf')
p = input

def cal(l, a, b=MIN):
	if b == MIN:
		b = a
	l1 = l.copy()
	l2 = l.copy()
	for i in r(l1):
		if l1[i] == -1:
			l1[i] = a
	(m1, m2) = (MIN, MIN)
	for i in range(1, len(l)):
		m1 = max(m1, abs(l1[i] - l1[i - 1]))
	for i in r(l2):
		if l2[i] == -1:
			l2[i] = b
	for i in range(1, len(l)):
		m2 = max(m2, abs(l2[i] - l2[i - 1]))
	if m1 < m2:
		print(m1, a)
	else:
		print(m2, b)
for _ in range(o()):
	n = o()
	l = op()
	(m1, m2) = (MAX, MIN)
	if l == [-1] * n:
		print(0, 1)
		continue
	for i in r(l):
		if l[i] == -1:
			if i != 0:
				if l[i - 1] != -1:
					m1 = min(m1, l[i - 1])
				m2 = max(m2, l[i - 1])
			if i != len(l) - 1:
				if l[i + 1] != -1:
					m1 = min(m1, l[i + 1])
				m2 = max(m2, l[i + 1])
	if m1 + m2 & 1:
		cal(l, (m1 + m2) // 2, (m1 + m2 + 1) // 2)
	else:
		cal(l, (m1 + m2) // 2)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mn = 10 ** 9
	mx = -1
	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])
	res = (mn + mx) // 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)


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


def run_length_compress(string):
	string.append('@')
	n = len(string)
	begin = 0
	end = 1
	cnt = 1
	ans = []
	while True:
		if end >= n:
			break
		if string[begin] == string[end]:
			end += 1
			cnt += 1
		else:
			ans.append(string[begin])
			begin = end
			end = begin + 1
			cnt = 1
	return ans
import sys
input = sys.stdin.readline
t = int(input())
INF = 10 ** 18
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	max_a = 0
	min_a = INF
	adj = 0
	b = run_length_compress(a)
	for (i, num) in enumerate(b):
		if b[i] == -1:
			if i - 1 >= 0:
				if b[i - 1] != -1:
					min_a = min(min_a, b[i - 1])
					max_a = max(max_a, b[i - 1])
			if i + 1 < len(b):
				if b[i + 1] != -1:
					min_a = min(min_a, b[i + 1])
					max_a = max(max_a, b[i + 1])
		else:
			if i - 1 >= 0:
				if b[i - 1] != -1:
					adj = max(adj, abs(b[i - 1] - b[i]))
			if i + 1 < len(b):
				if b[i + 1] != -1:
					adj = max(adj, abs(b[i + 1] - b[i]))
	if min_a == INF:
		print(0, 0)
	else:
		print(max(adj, (max_a + 1 - min_a) // 2), min_a + (max_a + 1 - min_a) // 2)


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


from math import *
for i in range(int(input())):
	(n, a) = (int(input()), list(map(int, input().split())))
	(mi, ma, diff) = (float('inf'), -1, 0)
	for j in range(n):
		if j > 0:
			if a[j - 1] == -1 and a[j] != -1:
				(mi, ma) = (min(mi, a[j]), max(ma, a[j]))
			elif a[j - 1] != -1 and a[j] != -1:
				diff = max(diff, abs(a[j] - a[j - 1]))
		if j < n - 1 and a[j] != -1 and (a[j + 1] == -1):
			(mi, ma) = (min(mi, a[j]), max(ma, a[j]))
	if mi == float('inf') or ma == -1:
		print(0, 1)
	else:
		diff2 = ceil((ma + mi) / 2)
		print(max(ma - diff2, diff2 - mi, diff), diff2)


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


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)


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

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

def mi():
	return map(int, input().split())
for _ in range(int(input())):
	n = ii()
	lst = ai()
	nlst = []
	for (ind, ele) in enumerate(lst):
		if ele == -1:
			if ind != 0 and lst[ind - 1] != -1:
				nlst.append(lst[ind - 1])
			if ind != n - 1 and lst[ind + 1] != -1:
				nlst.append(lst[ind + 1])
	if len(nlst) != 0:
		(mx, mn) = (max(nlst), min(nlst))
		k = (mx + mn) // 2
		nlst = [k if i == -1 else i for i in lst]
		m = 0
		for i in range(1, n):
			m = max(m, abs(nlst[i] - nlst[i - 1]))
		print(m, k)
	else:
		print(0, 1)


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)


t = int(input())
for _ in range(t):
	n = int(input())
	diff = []
	z = []
	l = list(map(int, input().split()))
	if l.count(-1) == n:
		print(0, 10)
	else:
		for i in range(len(l) - 1):
			if l[i] != -1 and l[i + 1] != -1:
				diff.append(abs(l[i] - l[i + 1]))
		for i in range(1, n - 1):
			if l[i] != -1 and (l[i - 1] == -1 or l[i + 1] == -1):
				z.append(l[i])
		if l[1] == -1 and l[0] != -1:
			z.append(l[0])
		if l[-2] == -1 and l[-1] != -1:
			z.append(l[-1])
		if len(diff) != 0:
			d = max(diff)
		else:
			d = 0
		a = max(z)
		b = min(z)
		c = (a + b) // 2
		m = max(abs(a - c), abs(b - c), d)
		print(m, c)


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)


def binarySearch(arr, x):
	l = 0
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
from math import *

def ceil(a, b):
	if a % b == 0:
		return int(a / b)
	else:
		return a // b + 1

def c(ar, n):
	m = 0
	for i in range(len(ar) - 1):
		if ar[i] == -1 and ar[i + 1] == -1:
			m = max(m, abs(n - n))
		elif ar[i] == -1:
			m = max(m, abs(n - ar[i + 1]))
		elif ar[i + 1] == -1:
			m = max(m, abs(ar[i] - n))
		else:
			m = max(m, abs(ar[i] - ar[i + 1]))
	return m
for __ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	l = 0
	r = 1000000010
	ans = 0
	while l <= r:
		m = (l + r) // 2
		if c(ar, m) > c(ar, m - 1) and m - 1 >= 0:
			r = m - 1
			ans = m - 1
		elif c(ar, m) == c(ar, m - 1) and m - 1 >= 0:
			ans = m
			break
		elif c(ar, m) > c(ar, m + 1):
			l = m + 1
			ans = m + 1
		else:
			ans = m
			break
	print(c(ar, ans), ans)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	t = l.count(-1)
	s = set()
	for i in range(n - 1):
		if l[i] == -1 and l[i + 1] != -1:
			s.add(l[i + 1])
		elif l[i] != -1 and l[i + 1] == -1:
			s.add(l[i])
	su = sum(list(s))
	c = len(s)
	if t == n:
		print(0, 1)
	else:
		s = list(s)
		q = (max(s) + min(s)) // 2
		for i in range(n):
			if l[i] == -1:
				l[i] = q
		x = []
		for i in range(n - 1):
			x.append(abs(l[i] - l[i + 1]))
		print(max(x), q)


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)


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


import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = pow(10, 9) + 7

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

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

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

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

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

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

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nl():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def solve():
	n = int(inp())
	a = lis()
	arr = []
	for i in range(0, n):
		if a[i] == -1:
			continue
		if i == 0:
			if a[i + 1] == -1:
				arr.append(a[i])
			continue
		if i == n - 1:
			if a[i - 1] == -1:
				arr.append(a[i])
			continue
		if a[i - 1] == -1 or a[i + 1] == -1:
			arr.append(a[i])
	if len(arr) == 0:
		print(0, 0)
	else:
		k = (max(arr) + min(arr)) // 2
		st = max(0, k - 10)
		val = -1
		ans = mod
		for i in range(st, k + 10):
			lol = []
			for j in range(0, n):
				if a[j] == -1:
					lol.append(i)
				else:
					lol.append(a[j])
			temp = -1
			for j in range(1, n):
				temp = max(temp, abs(lol[j] - lol[j - 1]))
			if temp < ans:
				ans = temp
				val = i
		print(ans, val)
testcase(int(inp()))


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)


def check(a: list, m: int, n: int) -> bool:
	l = -1
	r = int(1000000000.0)
	for i in range(1, n + 1):
		if a[i] == -1:
			lt = rt = 0
			if a[i - 1] == -1 and a[i + 1] == -1:
				continue
			elif a[i - 1] == -1 and a[i + 1] != -1:
				lt = a[i + 1] - m
				rt = a[i + 1] + m
			elif a[i - 1] != -1 and a[i + 1] == -1:
				lt = a[i - 1] - m
				rt = a[i - 1] + m
			else:
				rt = min(a[i - 1], a[i + 1]) + m
				lt = max(a[i + 1], a[i - 1]) - m
			l = max(l, lt)
			r = min(r, rt)
			if l > r:
				return False
		elif a[i - 1] != -1 and abs(a[i - 1] - a[i]) > m:
			return False
	global k
	k = r
	return True
for _ in range(int(input())):
	n = int(input())
	a = [-1] + list(map(int, input().split())) + [-1]
	lm = k = 0
	rm = int(1000000000.0)
	while lm < rm:
		mid = lm + rm >> 1
		if check(a, mid, n):
			rm = mid
		else:
			lm = mid + 1
	print(rm, 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)


import sys
input = lambda : sys.stdin.readline().rstrip()

def dp_(mi):
	dp = [0]
	for i in range(len(mi) - 1):
		dp.append(abs(mi[i] - mi[i + 1]))
	return dp

def main():
	for _ in range(int(input())):
		l = int(input())
		mas = list(map(int, input().split()))
		c = []
		an = []
		for i in range(l):
			if mas[i] == -1:
				an.append(i)
				if i == 0:
					if mas[i + 1] != -1:
						c.append(mas[i + 1])
				elif i == l - 1:
					if mas[i - 1] != -1:
						c.append(mas[i - 1])
				else:
					if mas[i - 1] != -1:
						c.append(mas[i - 1])
					if mas[i + 1] != -1:
						c.append(mas[i + 1])
		g = 0
		if len(c) != 0:
			ans = (max(c) + min(c)) // 2
			for i in an:
				mas[i] = ans
			print(max(dp_(mas)), ans)
		else:
			print(0, 1)
main()


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)


y = int(input())
for i in range(y):
	n = int(input())
	al = input().split()
	m = list(map(int, al))
	maxe = 0
	mine = int(1000000000.0)
	maxdiff = 0
	for j in range(n - 1):
		if m[j] > maxe and m[j + 1] == -1 and (m[j] != -1):
			maxe = m[j]
		if m[j] < mine and m[j + 1] == -1 and (m[j] != -1):
			mine = m[j]
		if m[j + 1] > maxe and m[j] == -1 and (m[j + 1] != -1):
			maxe = m[j + 1]
		if m[j + 1] < mine and m[j] == -1 and (m[j + 1] != -1):
			mine = m[j + 1]
		if j < n - 1 and (m[j + 1] != -1 and m[j] != -1):
			if maxdiff < abs(m[j + 1] - m[j]):
				maxdiff = abs(m[j + 1] - m[j])
	t = int((maxe + mine) / 2)
	t1 = max(maxe - t, t - mine)
	print(max(maxdiff, t1), 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)


def solve_m(a, k):
	l = 0
	r = 10 ** 9
	for i in range(len(a) - 1):
		if a[i] == -1 and a[i + 1] != -1:
			l = max(l, a[i + 1] - k)
			r = min(r, a[i + 1] + k)
		elif a[i + 1] == -1 and a[i] != -1:
			l = max(l, a[i] - k)
			r = min(r, a[i] + k)
	return -1 if l > r else l

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	l = 0
	h = 10 ** 9
	for i in range(n - 1):
		if a[i] != -1 and a[i + 1] != -1:
			l = max(l, abs(a[i] - a[i + 1]))
	while l < h:
		mid = (l + h) // 2
		if solve_m(a, mid) != -1:
			h = mid
		else:
			l = mid + 1
	print(l, solve_m(a, l))
t = int(input())
while t:
	t -= 1
	solve()


from math import ceil
from math import sqrt
from math import factorial
from collections import Counter
from operator import itemgetter
i = lambda : input()
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
t = ii()
for _ in range(t):
	n = ii()
	a = iia()
	b = []
	if a[0] == -1 and a[1] != -1:
		b.append(a[1])
	if a[1] == -1 and a[0] != -1:
		b.append(a[0])
	if a[-1] == -1 and a[-2] != -1:
		b.append(a[-2])
	if a[-2] == -1 and a[-1] != -1:
		b.append(a[-1])
	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 len(b) == 0:
		b.append(1)
	b = list(set(b))
	b.sort()
	p = ceil((b[0] + b[-1]) / 2)
	c = 0
	for i in range(len(a)):
		if a[i] == -1:
			a[i] = p
	for i in range(1, n):
		c = max(c, abs(a[i] - a[i - 1]))
	print(c, p)


import math
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = list(l)
	l1 = set()
	for i in range(n):
		if l[i] == -1:
			if i - 1 >= 0 and l[i - 1] != -1:
				l1.add(l[i - 1])
			if i + 1 < n and l[i + 1] != -1:
				l1.add(l[i + 1])
	l1 = list(l1)
	if len(l1) >= 2:
		l1.sort()
		ma = l1[0]
		mi = l1[len(l1) - 1]
		avg = (ma + mi) // 2
		for i in range(n):
			if l[i] == -1:
				l[i] = avg
		ma = 0
		for i in range(1, n):
			if ma < abs(l[i] - l[i - 1]):
				ma = abs(l[i] - l[i - 1])
		print(ma, avg)
	elif len(l1) == 1:
		ma = 0
		for i in range(n):
			if l[i] == -1:
				l[i] = l1[0]
		for i in range(1, n):
			if ma < abs(l[i] - l[i - 1]):
				ma = abs(l[i] - l[i - 1])
		print(ma, l1[0])
	elif len(l1) == 0:
		print('0', '1')


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)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	arr = []
	for i in range(n):
		if a[i] == -1:
			if i == 0:
				if a[i + 1] >= 0:
					arr.append(a[i + 1])
			elif i == n - 1:
				if a[i - 1] >= 0:
					arr.append(a[i - 1])
			else:
				if a[i - 1] >= 0:
					arr.append(a[i - 1])
				if a[i + 1] >= 0:
					arr.append(a[i + 1])
	if len(arr) == 0:
		print('0 3')
	else:
		mn = min(arr)
		m = max(arr)
		x = (mn + m) // 2
		ans = []
		for i in range(0, n):
			if a[i] == -1:
				a[i] = x
		for i in range(1, n):
			ans.append(abs(a[i] - a[i - 1]))
		print(max(ans), x)


import sys
inp = sys.stdin.readline
input = lambda : inp().strip()
flush = sys.stdout.flush

def iin():
	return int(input())

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

def main():
	T = iin()
	while T:
		T -= 1
		n = iin()
		a = lin()

		def find(i):
			m1 = 0
			for j in range(n - 1):
				x = i if a[j] == -1 else a[j]
				m1 = max(m1, abs(x - (a[j + 1] if a[j + 1] != -1 else i)))
			return m1
		(l, r) = (0, 10 ** 9)
		ans = [find(0), 0]
		while l < r:
			md = l + (r - l) // 2
			(x1, x2) = (find(md), find(md + 1))
			if x1 > x2:
				l = md + 1
			else:
				r = md - 1
			ans = min(ans, [x1, md], [x2, md + 1])
		print(*ans)
main()


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)


for _ in range(int(input())):
	n = int(input())
	arr = [int(a) for a in input().split()]
	b = []
	md = 0
	k = 42
	for (i, item) in enumerate(arr):
		if item > -1:
			if i > 0:
				if arr[i - 1] > -1:
					md = max(md, abs(arr[i - 1] - arr[i]))
				if arr[i - 1] == -1:
					b.append(item)
			if i < n - 1:
				if arr[i + 1] > -1:
					md = max(md, abs(arr[i] - arr[i + 1]))
				if arr[i + 1] == -1:
					b.append(item)
	if b != []:
		k = (max(b) + min(b)) // 2
		md = max(md, max(abs(k - max(b)), abs(k - min(b))))
	print(md, k)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	b = []
	for i in range(n):
		if a[i] != -1 and (i > 0 and a[i - 1] == -1 or (i < n - 1 and a[i + 1] == -1)):
			b.append(a[i])
	if not b:
		k = 0
	else:
		mn = min(b)
		mx = max(b)
		k = round((mn + mx) / 2)
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	m = 0
	for i in range(1, n):
		diff = abs(a[i] - a[i - 1])
		m = max(diff, m)
	print(m, k)


def f(n, A, x):
	B = A[:]
	for i in range(n):
		if B[i] == -1:
			B[i] = x
	m = 0
	for i in range(n - 1):
		m = max(abs(B[i] - B[i + 1]), m)
	return m
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	a = input()
	A = list(map(int, list(a.split())))
	l = min(A)
	h = max(A)
	while l <= h:
		mid = (l + h) // 2
		if f(n, A, mid) <= f(n, A, mid - 1) and f(n, A, mid) <= f(n, A, mid + 1):
			if mid < 0:
				print(f(n, A, 0), end=' ')
				print(0)
			elif mid > 10 ** 9:
				prin(f(n, A, 10 ** 9), end=' ')
				print(10 ** 9)
			else:
				print(f(n, A, mid), end=' ')
				print(mid)
			break
		elif f(n, A, mid) > f(n, A, mid - 1):
			h = mid - 1
		elif f(n, A, mid) < f(n, A, mid - 1):
			l = mid + 1


def calc(val, lista):
	mx = 0
	for i in range(1, len(lista)):
		(x, y) = (lista[i], lista[i - 1])
		if x == -1:
			x = val
		if y == -1:
			y = val
		mx = max(mx, abs(x - y))
	return mx
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	(l, ret, h, m) = (0, 0, 10000000000, 10000000000)
	while l < h:
		mid = (l + (h - 1)) // 2
		mx1 = calc(mid, a)
		mx2 = calc(mid + 1, a)
		if mx1 <= mx2:
			m = mx1
			h = mid
		else:
			m = mx2
			ret = mid + 1
			l = mid + 1
	if m == 10000000000:
		m = 0
	print(m, ret)


t = int(input())
for case in range(1, t + 1):
	n = int(input())
	a = [int(x) for x in input().split()]
	assert len(a) == n
	caps = []
	for (i, x) in enumerate(a):
		if x == -1:
			if i > 0 and a[i - 1] != -1:
				caps.append(a[i - 1])
			if i < n - 1 and a[i + 1] != -1:
				caps.append(a[i + 1])
	if caps:
		k = round((max(caps) + min(caps)) / 2)
	else:
		k = 42
	a_complete = [x if x != -1 else k for x in a]
	m = max((abs(a_complete[i] - a_complete[i - 1]) for i in range(1, n)))
	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)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	m = []
	diff = 0
	if arr[0] == -1 and arr[1] != -1:
		m.append(arr[1])
	if arr[-1] == -1 and arr[-2] != -1:
		m.append(arr[-2])
	for i in range(1, n - 1):
		if arr[i] == -1:
			if arr[i - 1] != -1:
				m.append(arr[i - 1])
			if arr[i + 1] != -1:
				m.append(arr[i + 1])
		else:
			if arr[i - 1] != -1:
				diff = max(diff, abs(arr[i] - arr[i - 1]))
			if arr[i + 1] != -1:
				diff = max(diff, abs(arr[i] - arr[i + 1]))
	if len(m) == 0:
		print(0, 69)
	else:
		ma = max(m)
		mi = min(m)
		val = (ma + mi) // 2
		diff = max(diff, abs(val - ma), abs(val - mi))
		print(diff, val)


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


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

def si():
	return input().rstrip()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def solve():
	for _ in range(ii()):
		n = ii()
		a = li()

		def can(x):
			mx = 0
			b = []
			for i in range(n):
				if a[i] == -1:
					b.append(x)
				else:
					b.append(a[i])
			for i in range(1, n):
				mx = max(mx, abs(b[i] - b[i - 1]))
			return mx
		l = 0
		r = int(1000000000.0)
		while l <= r:
			m = l + (r - l) // 2
			x = can(m)
			if m > 0:
				x1 = can(m - 1)
			if m < int(1000000000.0):
				x2 = can(m + 1)
			if x <= x1 and x <= x2:
				ans1 = m
				ans2 = x
				break
			if x1 < x2:
				ans1 = m - 1
				ans2 = x1
				r = m - 1
			else:
				l = m + 1
		print(ans2, ans1)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


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)


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	ntest = int(stdin.readline())
	for test in range(ntest):
		n = int(stdin.readline().strip())
		a = [int(x) for x in stdin.readline().strip().split()]
		vset = set(a)
		if len(vset) <= 2:
			stdout.write('0 %d\n' % max(max(vset), 0))
			continue
		minm = 0
		dset = set()
		for i in range(1, n):
			if a[i] == a[i - 1]:
				continue
			if -1 not in [a[i - 1], a[i]]:
				minm = max(minm, abs(a[i - 1] - a[i]))
			else:
				dset.add(max(a[i - 1], a[i]))
		k = trunc((max(dset) + min(dset) + 1) / 2)
		m = max(max(max(dset) - k, k - min(dset)), minm)
		stdout.write('%d %d\n' % (m, k))
	return 0
main()


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)


def want(num):
	L = 0
	R = 10 ** 9
	for i in range(n - 1):
		if a[i] != -1 and a[i + 1] != -1:
			if abs(a[i] - a[i + 1]) > num:
				return -1
		elif a[i] == -1 and a[i + 1] != -1:
			L = max(L, a[i + 1] - num)
			R = min(R, a[i + 1] + num)
			if L > a[i + 1] + num or R < a[i + 1] - num:
				return -1
		elif a[i] != -1 and a[i + 1] == -1:
			L = max(L, a[i] - num)
			R = min(R, a[i] + num)
			if L > a[i] + num or R < a[i] - num:
				return -1
		if L > R:
			return -1
	return L
t = int(input())
nans = 0
for loop in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	l = -1
	r = 10 ** 9
	while r - l != 1:
		m = (r + l) // 2
		ret = want(m)
		if ret < 0:
			l = m
		else:
			r = m
			nans = ret
	print(r, nans)


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


from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

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

def intsput():
	return map(int, sinput())

class RangedList:

	def __init__(self, start, stop, val=0):
		self.shift = 0 - start
		self.start = start
		self.stop = stop
		self.list = [val] * (stop - start)

	def __setitem__(self, key, value):
		self.list[key + self.shift] = value

	def __getitem__(self, key):
		return self.list[key + self.shift]

	def __repr__(self):
		return str(self.list)

	def __iter__(self):
		return iter(self.list)
t = intput()
for _ in range(t):
	n = intput()
	a = list(intsput())
	b = []
	for i in range(n):
		if a[i] == -1:
			for j in (i - 1, i + 1):
				if j in range(n) and a[j] != -1:
					b.append(a[j])
	if not b:
		print(0, 10)
		continue
	large = max(b)
	small = min(b)
	k = small + (large - small) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	found = 0
	for i in range(1, n):
		found = max(found, abs(a[i] - a[i - 1]))
	print(found, k)


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 string

def main():
	n = int(input())
	lst = list(map(int, input().split()))
	maxdif = 0
	mindif = 9999999999999
	amm = 0
	if lst[0] == -1 and lst[1] != -1:
		amm += 1
		maxdif = max(maxdif, lst[1])
		mindif = min(mindif, lst[1])
	if lst[-1] == -1 and lst[-2] != -1:
		amm += 1
		maxdif = max(maxdif, lst[-2])
		mindif = min(mindif, lst[-2])
	for i in range(1, n - 1):
		if lst[i] == -1:
			if lst[i - 1] != -1:
				amm += 1
				maxdif = max(maxdif, lst[i - 1])
				mindif = min(mindif, lst[i - 1])
			if lst[i + 1] != -1:
				amm += 1
				maxdif = max(maxdif, lst[i + 1])
				mindif = min(mindif, lst[i + 1])
	num = (maxdif + mindif) // 2
	if amm == 0:
		print(0, 47)
		return
	m = 0
	for i in range(0, n):
		if lst[i] == -1:
			lst[i] = num
	for i in range(0, n - 1):
		m = max(m, abs(lst[i] - lst[i + 1]))
	print(m, num)
t = int(input())
for i in range(t):
	main()


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


I = input
for _ in [0] * int(I()):
	n = int(I())
	a = (*map(int, I().split()),)
	b = [i for (i, x) in enumerate(a) if x < 0]
	l = 0
	r = []
	for (i, j) in zip([-1] + b, b + [n]):
		if j > i + 1:
			d = a[i + 1:j]
			l = max(l, l, *(abs(x - y) for (x, y) in zip(d, d[1:])))
			r += ([], [a[i + 1]])[i >= 0] + ([], [a[j - 1]])[j < n]
	r = r or [0]
	m = min(r)
	z = (max(r) - m + 1) // 2
	print(max(z, l), m + z)


def solve_b():
	n = int(input())
	for _ in range(n):
		b()

def b():
	n = int(input())
	l = [int(x) for x in input().split()]
	l2 = []
	l2 = [l[index - 1] for (index, x) in enumerate(l) if index > 0 and x == -1 and (l[index - 1] != -1)] + [l[index + 1] for (index, x) in enumerate(l) if index < n - 1 and x == -1 and (l[index + 1] != -1)]
	if l2 == []:
		print('{} {}'.format(0, 42))
		return
	min_l2 = min(l2)
	max_l2 = max(l2)
	k = (min_l2 + max_l2) // 2
	l3 = [x if x != -1 else k for x in l]
	m = max([abs(l3[index] - l3[index + 1]) for (index, x) in enumerate(l3[:n - 1])])
	print('{} {}'.format(m, k))
solve_b()


I = input
for _ in [0] * int(I()):
	I()
	a = (*map(int, I().split()),)
	b = [i for (i, x) in enumerate(a) if x < 0]
	c = [a[i + 1:j] for (i, j) in zip([-1] + b, b + [len(a)]) if j > i + 1]
	b = []
	for d in c:
		b += (d[0], d[-1])
	for i in (0, -1):
		if a[i] + 1:
			b.pop(i)
	b = b or [0]
	m = min(b)
	z = (max(b) - m + 1) // 2
	print(max(z, z, *(abs(x - y) for d in c for (x, y) in zip(d, d[1:]))), m + z)


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)


kl = int(input())
for l in range(kl):
	n = int(input())
	s = [int(i) for i in input().split()]
	mxr = 0
	mnr = 1000000001
	d = 0
	for i in range(1, n):
		if s[i - 1] == -1 and s[i] == -1:
			continue
		elif s[i - 1] == -1 and s[i] != -1:
			mxr = max(mxr, s[i])
			mnr = min(mnr, s[i])
		elif s[i - 1] != -1 and s[i] == -1:
			mxr = max(mxr, s[i - 1])
			mnr = min(mnr, s[i - 1])
		elif s[i - 1] != -1 and s[i] != -1:
			d = max(d, abs(s[i] - s[i - 1]))
	k = mnr + (mxr - mnr) // 2
	print(max(d, mxr - k, k - mnr), 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)


def tc():
	n = int(input())
	a = list(map(int, input().split()))
	m = 0
	minx = float('inf')
	maxx = 0
	for i in range(1, n):
		if a[i] == -1 and a[i - 1] == -1:
			continue
		elif a[i] != -1 and a[i - 1] != -1:
			m = max(abs(a[i] - a[i - 1]), m)
		else:
			x = a[i] if a[i - 1] == -1 else a[i - 1]
			minx = min(x, minx)
			maxx = max(x, maxx)
	k = (minx + maxx) // 2
	if k != k:
		k = 1
	m = max(m, maxx - k, k - minx)
	print(m, k)
T = int(input())
for _ in range(T):
	tc()


import sys
input = sys.stdin.readline
for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = a.count(-1)
	if c == n:
		print(0, 1)
		continue
	elif c == n - 1:
		print(0, sum(a) + n - 1)
		continue
	minn = max(a)
	maxx = 0
	for i in range(1, n):
		if a[i] == -1 and a[i - 1] != -1:
			minn = min(minn, a[i - 1])
			maxx = max(maxx, a[i - 1])
	for i in range(n - 1):
		if a[i] == -1 and a[i + 1] != -1:
			minn = min(minn, a[i + 1])
			maxx = max(maxx, a[i + 1])
	ans = (minn + maxx) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = ans
	maxx = 0
	for i in range(1, n):
		maxx = max(maxx, abs(a[i] - a[i - 1]))
	print(maxx, ans)


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)


for _ in range(int(input())):
	x = int(input())
	arr = list(map(int, input().split()))
	tar = []
	for i in range(x - 1):
		if arr[i] != -1 and arr[i + 1] == -1:
			tar.append(arr[i])
		elif arr[i] == -1 and arr[i + 1] != -1:
			tar.append(arr[i + 1])
	if not tar:
		print(0, 0)
	else:
		k = (max(tar) + min(tar) + 1) // 2
		m = 0
		for i in range(x):
			if arr[i] == -1:
				arr[i] = k
		for i in range(x - 1):
			m = max(m, abs(arr[i] - arr[i + 1]))
		print(m, k)


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


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)


import sys
input = sys.stdin.buffer.readline

def print(*vals):
	sys.stdout.write(' '.join(map(str, vals)) + '\n')

def max_diff(integers, k, n):
	max_diff = 0
	for i in range(n - 1):
		if integers[i] == -1 and integers[i + 1] != -1:
			max_diff = max(max_diff, abs(k - integers[i + 1]))
		elif integers[i + 1] == -1 and integers[i] != -1:
			max_diff = max(max_diff, abs(integers[i] - k))
		else:
			max_diff = max(max_diff, abs(integers[i] - integers[i + 1]))
	return max_diff

def prog():
	for _ in range(int(input())):
		n = int(input())
		integers = list(map(int, input().split()))
		L = 0
		R = 10 ** 9
		while L != R:
			diff = (R - L) // 3
			m1 = L + diff
			m2 = R - diff
			val1 = max_diff(integers, m1, n)
			val2 = max_diff(integers, m2, n)
			if val1 > val2:
				L = m1 + 1
			else:
				R = m2 - 1
		print(max_diff(integers, R, n), R)
prog()


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


import sys, math
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
t = 1
t = inp()
for tt in range(t):
	n = inp()
	a = inlt()
	b = []
	a.append(a[-1] + 1)
	for i in range(len(a) - 1):
		if a[i] != a[i + 1]:
			b.append(a[i])
	a = list(b)
	if len(set(a)) == 1 and -1 in a:
		print(0, 0)
		continue
	else:
		for i in range(len(a)):
			if a[i] != -1:
				break
		a = [a[i]] + a
		for i in range(len(a) - 1, -1, -1):
			if a[i] != -1:
				break
		a = a + [a[i]]
	k = 0
	kk = 9999999999999
	w = max(a[0], a[1])
	for i in range(1, len(a) - 1):
		if a[i] == -1:
			q = max(a[i + 1], a[i - 1]) - (a[i + 1] + a[i - 1]) // 2
			if q > k:
				k = q
				w = (a[i + 1] + a[i - 1]) // 2
	a.append(a[-1])
	k = 0
	w = min(w, w)
	b = list(a)
	for i in range(len(a) - 1):
		if a[i] == -1:
			a[i] = w
	for i in range(len(a) - 1):
		k = max(abs(a[i + 1] - a[i]), k)
	kk = 0
	a = list(b)
	qq = 999999999999
	ww = 0
	for i in range(1, len(a) - 1):
		if a[i] == -1:
			qq = min(qq, a[i + 1], a[i - 1])
			ww = max(ww, a[i + 1], a[i - 1])
	ww = (ww + qq) // 2
	for i in range(len(a) - 1):
		if a[i] == -1:
			a[i] = ww
	for i in range(len(a) - 1):
		kk = max(abs(a[i + 1] - a[i]), kk)
	if kk < k:
		print(kk, ww)
	else:
		print(k, w)


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)


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


import sys
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	maxi = -sys.maxsize
	mini = sys.maxsize
	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]))
	for i in range(n):
		if a[i] != -1:
			if i - 1 >= 0 and a[i - 1] == -1:
				mini = min(mini, a[i])
				maxi = max(maxi, a[i])
			if i + 1 < n and a[i + 1] == -1:
				mini = min(mini, a[i])
				maxi = max(maxi, a[i])
	k = (mini + maxi + 1) // 2
	print(max(m, maxi - k, k - mini), k)


t = int(input())
for i in range(0, t):
	li = []
	n = int(input())
	a = [int(x) for x in input().split()]
	if a[0] == -1 and a[1] != -1:
		li.append(a[1])
	for j in range(1, n - 1):
		if a[j] == -1:
			if a[j - 1] != -1:
				li.append(a[j - 1])
			if a[j + 1] != -1:
				li.append(a[j + 1])
	if a[-1] == -1 and a[-2] != -1:
		li.append(a[-2])
	if li == []:
		mx = 0
		mn = 0
	else:
		mn = min(li)
		mx = max(li)
	value = (mn + mx) // 2
	for j in range(0, n):
		if a[j] == -1:
			a[j] = value
	maxdiff = 0
	maxdiff = max(maxdiff, abs(a[0] - a[1]))
	maxdiff = max(maxdiff, abs(a[-1] - a[-2]))
	for j in range(1, n - 1):
		maxdiff = max(maxdiff, abs(a[j] - a[j - 1]))
	print(maxdiff, value)


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)


mod = 10 ** 9 + 7
import math
from bisect import bisect_left
from collections import Counter
from itertools import combinations

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

def fain():
	return map(float, input().split())

def f(x, y):
	return (x | y) - y
for _ in range(int(input())):
	n = int(input())
	ls = list(ain())
	l = []
	if ls[1] == -1 and ls[0] != -1:
		l.append(ls[0])
	if ls[-2] == -1 and ls[-1] != -1:
		l.append(ls[-1])
	m = 0
	if ls[0] != -1 and ls[1] != -1:
		m = max(m, abs(ls[1] - ls[0]))
	for i in range(1, n - 1):
		if ls[i] != -1 and (ls[i - 1] == -1 or ls[i + 1] == -1):
			l.append(ls[i])
		if ls[i] != -1 and ls[i + 1] != -1:
			m = max(m, abs(ls[i + 1] - ls[i]))
	if len(l) > 0:
		l.sort()
		maxv = max(l)
		minv = min(l)
		val = (maxv + minv) // 2
		dif = max(maxv - val, val - minv)
		print(max(m, dif), val)
	else:
		print(m, 42)


import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		lst = []
		if arr[0] == -1 and arr[1] != -1:
			lst.append(arr[1])
		if arr[-1] == -1 and arr[-2] != -1:
			lst.append(arr[-2])
		for i in range(1, n - 1):
			if arr[i] == -1 and arr[i - 1] != -1:
				lst.append(arr[i - 1])
			if arr[i] == -1 and arr[i + 1] != -1:
				lst.append(arr[i + 1])
		ans = 0
		for i in range(1, n):
			if arr[i] != -1 and arr[i - 1] != -1:
				ans = max(ans, abs(arr[i] - arr[i - 1]))
		x = 10
		if len(lst):
			(y, z) = (min(lst), max(lst))
			x = (y + z) // 2
			ans = max(ans, (z - y + 1) // 2)
		print(ans, x)
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()


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)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mn = 10 ** 9 + 1
	mx = -1
	realmx = 0
	realmn = 0
	for i in range(n):
		if arr[i] < 0:
			if i > 0 and arr[i - 1] != -1:
				mx = max(arr[i - 1], mx)
				mn = min(arr[i - 1], mn)
			if i < n - 1 and arr[i + 1] != -1:
				mx = max(arr[i + 1], mx)
				mn = min(arr[i + 1], mn)
		elif i > 0 and arr[i - 1] != -1:
			realmx = max(realmx, abs(arr[i] - arr[i - 1]))
			realmm = min(realmx, abs(arr[i] - arr[i - 1]))
	ans = (mx + mn) // 2
	dist_ans = mx - ans
	if dist_ans >= realmx:
		print(dist_ans, ans)
	else:
		print(realmx - realmn, ans)


n = int(input())
for i in range(n):
	mySet = set()
	t = int(input())
	numbers = [int(i) for i in input().split()]
	soFarMax = 0
	exchange = 0
	for (index, number) in enumerate(numbers):
		if number == -1:
			if index == 0:
				mySet.add(numbers[index + 1])
			elif index == t - 1:
				mySet.add(numbers[index - 1])
			else:
				mySet.add(numbers[index + 1])
				mySet.add(numbers[index - 1])
		elif index == 0:
			if numbers[index + 1] != -1:
				soFarMax = max(soFarMax, abs(numbers[index] - numbers[index + 1]))
		elif index == t - 1:
			if numbers[index - 1] != -1:
				soFarMax = max(soFarMax, abs(numbers[index] - numbers[index - 1]))
		else:
			if numbers[index + 1] != -1:
				soFarMax = max(soFarMax, abs(numbers[index] - numbers[index + 1]))
			if numbers[index - 1] != -1:
				soFarMax = max(soFarMax, abs(numbers[index] - numbers[index - 1]))
	if -1 in mySet:
		mySet.remove(-1)
	if mySet:
		exchange = (min(mySet) + max(mySet)) // 2
		soFarMax = max(soFarMax, max(abs(exchange - min(mySet)), abs(exchange - max(mySet))))
	print(soFarMax, exchange)


from collections import Counter
from collections import defaultdict
import math
t = int(input())
for _ in range(0, t):
	n = int(input())
	a = list(map(int, input().split()))
	diff = 0
	q = []
	f = 0
	for i in range(0, n):
		if a[i] != -1:
			if i == 0 and a[i + 1] == -1:
				q.append(a[i])
			elif i == n - 1 and a[i - 1] == -1:
				q.append(a[i])
			elif i != 0 and i != n - 1 and (a[i - 1] == -1 or a[i + 1] == -1):
				q.append(a[i])
	if len(q) == 0:
		r1 = 0
		for i in range(0, n - 1):
			r1 = max(r1, abs(a[i] - a[i + 1]))
		print(r1, 0)
		continue
	q.sort()
	s1 = (q[0] + q[-1]) // 2
	s2 = math.ceil((q[0] + q[-1]) / 2)
	mx = max(q)
	mn = min(q)
	diff1 = 0
	w1 = [0] * n
	w2 = [0] * n
	for i in range(0, n):
		if a[i] == -1:
			w1[i] = s1
		else:
			w1[i] = a[i]
	for i in range(0, n):
		if a[i] == -1:
			w2[i] = s2
		else:
			w2[i] = a[i]
	r1 = 0
	r2 = 0
	for i in range(0, n - 1):
		r1 = max(r1, abs(w1[i] - w1[i + 1]))
		r2 = max(r2, abs(w2[i] - w2[i + 1]))
	if r1 < r2:
		print(r1, s1)
	else:
		print(r2, s2)


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)


import math
num_cases = int(input())
for i in range(num_cases):
	num_elements = int(input())
	array = [int(n) for n in input().split()]
	neighbors = list()
	maxDiff = 0
	for i in range(num_elements):
		if array[i] == -1:
			if i == 0:
				if array[i + 1] != -1:
					neighbors.append(array[i + 1])
			elif i == num_elements - 1:
				if array[i - 1] != -1:
					neighbors.append(array[i - 1])
			else:
				if array[i + 1] != -1:
					neighbors.append(array[i + 1])
				if array[i - 1] != -1:
					neighbors.append(array[i - 1])
		elif i != num_elements - 1 and array[i + 1] != -1 and (abs(array[i] - array[i + 1]) > maxDiff):
			maxDiff = abs(array[i] - array[i + 1])
	numberToReplace = round((max(neighbors, default=0) + min(neighbors, default=0)) / 2)
	maxDiff = max(maxDiff, abs(max(neighbors, default=0) - numberToReplace), abs(min(neighbors, default=0) - numberToReplace))
	if len(neighbors) == 0:
		print(str(maxDiff) + ' 0')
	else:
		print(str(maxDiff) + ' ' + str(numberToReplace))


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


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if all((x == -1 for x in a)):
		print(0, 42)
		continue
	pairs = zip(a, a[1:])
	pairs_filtered = filter(lambda t: (t[0] == -1 or t[1] == -1) and t[0] != t[1], pairs)
	nums = list(map(lambda t: t[0] if t[0] != -1 else t[1], pairs_filtered))
	res_n = (max(nums) + min(nums)) // 2
	a = list(map(lambda x: x if x != -1 else res_n, a))
	diff = map(lambda x: abs(x[0] - x[1]), zip(a, a[1:]))
	print(max(diff), res_n)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

def in_int():
	return int(input())

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

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

def in_ints():
	return map(int, input().split())
t = in_int()
while t > 0:
	t -= 1
	n = in_int()
	arr = in_list()
	mn = 10 ** 9
	mx = -1
	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])
	res = (mx + mn) // 2
	ans = 0
	for i in range(n):
		if arr[i] == -1:
			arr[i] = res
		if i > 0:
			ans = max(ans, abs(arr[i] - arr[i - 1]))
	print(ans, res)


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


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)


import math
t = int(input())
for T in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	diff = 0
	l = set()
	for i in range(n - 1):
		x = a[i]
		y = a[i + 1]
		if x != -1 and y != -1:
			diff = max([diff, abs(x - y)])
		elif x == -1 and y == -1:
			continue
		else:
			l.add(max([x, y]))
	if len(l) != 0:
		ansdif = math.ceil((max(l) - min(l)) / 2)
		ans = min(l) + ansdif
		diff = max([diff, ansdif])
	else:
		ans = 0
	print(diff, ans)


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


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	if array.count(-1) == n:
		print(*(0, 69))
		continue
	mini = 1e309
	maxi = -1e309
	for i in range(n):
		if array[i] == -1:
			if i - 1 >= 0:
				if array[i - 1] != -1:
					mini = min(mini, array[i - 1])
					maxi = max(maxi, array[i - 1])
			if i + 1 < n:
				if array[i + 1] != -1:
					mini = min(mini, array[i + 1])
					maxi = max(maxi, array[i + 1])
	ans = (mini + maxi) // 2
	for i in range(n):
		if array[i] == -1:
			array[i] = ans
	this = -1
	for i in range(n - 1):
		this = max(this, abs(array[i] - array[i + 1]))
	ans = [this, ans]
	print(*ans)


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)


import math

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		(mina, maxa) = (10 ** 9, -1)
		(m, k) = (0, 0)
		if set(a) == set([-1]):
			(m, k) = (0, 42)
		else:
			for j in range(n):
				if a[j] == -1:
					if j - 1 >= 0:
						tmp = a[j - 1]
						if tmp != -1:
							mina = min(mina, tmp)
							maxa = max(maxa, tmp)
					if j + 1 < n:
						tmp = a[j + 1]
						if tmp != -1:
							mina = min(mina, tmp)
							maxa = max(maxa, tmp)
				else:
					if j - 1 >= 0:
						if a[j - 1] != -1:
							m = max(m, abs(a[j] - a[j - 1]))
					if j + 1 < n:
						if a[j + 1] != -1:
							m = max(m, abs(a[j] - a[j + 1]))
			k = math.ceil((mina + maxa) / 2)
			m = max(m, abs(maxa - k), abs(k - mina))
		print(m, k)
main()


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))

def chars():
	s = cin()
	return list(s[:len(s) - 1])

def pl(a):
	for val in a:
		cout(str(val) + ' ')
	cout('\n')
(t,) = mp()
for _ in range(t):
	(n,) = mp()
	a = mp()
	maxi = -10 ** 9
	mini = 10 ** 9
	for i in range(n):
		if a[i] != -1:
			if i > 0 and a[i - 1] == -1:
				mini = min(mini, a[i])
				maxi = max(maxi, a[i])
			elif i < n - 1 and a[i + 1] == -1:
				maxi = max(maxi, a[i])
				mini = min(mini, a[i])
	m = 0
	k = (maxi + mini) // 2
	for i in range(n):
		if a[i] == -1:
			a[i] = k
		if i:
			m = max(m, abs(a[i] - a[i - 1]))
	pl([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=' ')


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations

def if_poss(x):
	mini = inf
	maxi = 0
	for i in range(n):
		if l[i] == -1:
			if i - 1 >= 0:
				if l[i - 1] != -1:
					mini = min(l[i - 1], mini)
					maxi = max(l[i - 1], maxi)
			if i + 1 < n:
				if l[i + 1] != -1:
					mini = min(l[i + 1], mini)
					maxi = max(l[i + 1], maxi)
		if l[i] != -1:
			if i - 1 >= 0 and l[i - 1] != -1:
				if abs(l[i] - l[i - 1]) > x:
					return False
	if abs(maxi - (mini + x)) <= x:
		hash[x] = mini + x
		return True
	elif abs(maxi - x - mini) <= x:
		hash[x] = maxi - x
		return True
	return False
t = int(input())
for _ in range(t):
	hash = defaultdict(int)
	n = int(input())
	l = list(map(int, input().split()))
	if -1 not in l:
		maxi = 0
		for i in range(n - 1):
			maxi = max(abs(l[i] - l[i + 1]), maxi)
		print(maxi)
		continue
	elif l.count(-1) == n:
		print(0, 0)
		continue
	mini = 0
	maxi = max(l)
	ans = 0
	while mini != maxi:
		mid = (mini + maxi) // 2
		if if_poss(mid):
			maxi = mid - 1
			if mid == 0:
				break
		else:
			mini = mid + 1
		if mini >= maxi:
			if if_poss(mini - 1):
				ans = mini - 1
				break
			if if_poss(mini):
				ans = mini
				break
			if if_poss(mini + 1):
				ans = mini + 1
				break
	print(ans, hash[ans])


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)


t = int(input())
for z in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ma = 0
	mi = 10 ** 9
	maM = 0
	i = 0
	j = 1
	f = 0
	while j < n:
		if a[j] == -1 and a[i] != -1:
			f = 1
			if a[i] > ma:
				ma = a[i]
			if a[i] < mi:
				mi = a[i]
		if a[i] == -1 and a[j] != -1:
			f = 1
			if a[j] > ma:
				ma = a[j]
			if a[j] < mi:
				mi = a[j]
		if a[i] != -1 and a[j] != -1:
			if abs(a[i] - a[j]) > maM:
				maM = abs(a[i] - a[j])
		i += 1
		j += 1
	k = (ma + mi) // 2
	m1 = max(abs(ma - k), abs(mi - k))
	m = max(m1, maM)
	if f == 0 and maM == 0:
		print(0, k)
	else:
		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 sys
from functools import reduce
from collections import Counter
import time
import datetime
from math import sqrt, gcd

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

def sip():
	return sys.stdin.readline()

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

def mips():
	return map(str, sys.stdin.readline().split())

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

def matip(n, m):
	lst = []
	for i in range(n):
		arr = lip()
		lst.append(arr)
	return lst

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

def minJumps(arr, n):
	jumps = [0 for i in range(n)]
	if n == 0 or arr[0] == 0:
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if i <= j + arr[j] and jumps[j] != float('inf'):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n - 1]

def dic(arr):
	return Counter(arr)

def check_prime(n):
	if n < 2:
		return False
	for i in range(2, int(n ** 0.5) + 1, 2):
		if n % i == 0:
			return False
	return True
t = ip()
while t:
	t -= 1
	n = ip()
	arr = lip()
	ma = -2
	mi = 10 ** 9 + 1
	for i in range(n):
		if arr[i] != -1:
			if i > 0:
				if arr[i - 1] == -1:
					ma = max(ma, arr[i])
					mi = min(mi, arr[i])
			if i < n - 1:
				if arr[i + 1] == -1:
					ma = max(ma, arr[i])
					mi = min(mi, arr[i])
	val = (ma + mi) // 2
	diff = 0
	if arr[0] == -1:
		arr[0] = val
	for i in range(1, n):
		if arr[i] == -1:
			arr[i] = val
		diff = max(diff, abs(arr[i] - arr[i - 1]))
	print(diff, val)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil, pi, sin, cos, acos, atan
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	stack = []
	ch = []
	for i in range(n):
		if arr[i] == -1:
			ch.append(i)
		elif len(ch) != 0:
			stack.append(ch)
			ch = []
	if len(ch) != 0:
		stack.append(ch)
	if arr.count(-1) == n:
		ans = '{} {}'.format(0, 1)
	else:
		ssum = 0
		ct = 0
		ss = []
		for i in stack:
			st = i[0]
			end = i[-1]
			if st - 1 >= 0:
				ss.append(arr[st - 1])
			if end + 1 < n:
				ss.append(arr[end + 1])
		val1 = ceil((min(ss) + max(ss)) / 2)
		val2 = floor((min(ss) + max(ss)) / 2)
		check = list(arr)
		for i in range(n):
			if arr[i] == -1:
				arr[i] = val1
		diff1 = -float('inf')
		for i in range(n - 1):
			diff1 = max(diff1, abs(arr[i] - arr[i + 1]))
		arr = list(check)
		for i in range(n):
			if arr[i] == -1:
				arr[i] = val2
		diff2 = -float('inf')
		for i in range(n - 1):
			diff2 = max(diff2, abs(arr[i] - arr[i + 1]))
		if diff1 > diff2:
			ans = '{} {}'.format(diff1, val1)
		else:
			ans = '{} {}'.format(diff2, val2)
	out(ans)


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)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m1 = 0
	ans2 = 0
	m2 = 999999999
	for i in range(n):
		if a[i] != -1:
			if i != n - 1 and a[i + 1] == -1:
				(m2, m1) = (min(m2, a[i]), max(m1, a[i]))
			if i and a[i - 1] == -1:
				(m1, m2) = (max(m1, a[i]), min(m2, a[i]))
	ans = (m1 + m2) // 2
	ans2 = 0
	for i in range(n - 1):
		if a[i] == a[i + 1] == -1:
			continue
		if a[i] == -1:
			ans2 = max(ans2, abs(ans - a[i + 1]))
			continue
		if a[i + 1] == -1:
			ans2 = max(ans2, abs(ans - a[i]))
			continue
		ans2 = max(ans2, abs(a[i] - a[i + 1]))
	print(ans2, ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	nei = []
	default = 0
	for (x, y) in zip(a, a[1:]):
		if x == -1 and y != -1:
			nei.append(y)
		if x != -1 and y == -1:
			nei.append(x)
		if x != -1 and y != -1:
			default = max(default, abs(x - y))
	if not nei:
		print(0, 1)
		continue
	mi = min(nei)
	ma = max(nei)
	k = (mi + ma) // 2
	m = max(abs(mi - k), abs(ma - k), default)
	print(m, k)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in range(1, n - 1):
		if a[i] > -1 and (a[i + 1] == -1 or a[i - 1] == -1):
			d[a[i]] = 1
	if a[0] > -1 and a[1] == -1:
		d[a[0]] = 1
	if a[-1] > -1 and a[-2] == -1:
		d[a[-1]] = 1
	diff = -1
	for i in range(1, n):
		if a[i] > -1 and a[i - 1] > -1:
			diff = max(diff, abs(a[i] - a[i - 1]))

	def check(k, d):
		mi = -10 ** 12
		ma = 10 ** 12
		for i in d:
			mi = max(mi, i - k, 0)
			ma = min(ma, i + k)
		if mi <= ma:
			return (1, mi)
		else:
			return (0, 0)
	if len(d) == 0:
		print(0, 5)
	else:
		low = diff
		high = 10 ** 12
		while low < high:
			mid = (low + high) // 2
			p = check(mid, d)
			if p[0]:
				ind = p[1]
				high = mid
			else:
				low = mid + 1
		p = check(low, d)
		print(low, p[1])


from __future__ import division
import math
T = int(input())
for case in range(T):
	N = int(input())
	arr = [int(x) for x in input().split()]
	cu = 0
	maxx = 0
	minn = 0
	n_maxx = 0
	neigh = []
	for pos in range(N):
		if arr[pos] == -1:
			for x in arr[pos - 1:pos] + arr[pos + 1:pos + 2]:
				if x != -1:
					neigh.append(x)
		elif arr[min(pos + 1, N - 1)] != -1:
			if abs(arr[pos] - arr[min(pos + 1, N - 1)]) > n_maxx:
				n_maxx = abs(arr[pos] - arr[min(pos + 1, N - 1)])
	for n in range(len(neigh)):
		if n == 0:
			maxx = neigh[n]
			minn = neigh[n]
		elif maxx < neigh[n]:
			maxx = neigh[n]
		elif minn > neigh[n]:
			minn = neigh[n]
	diff = maxx - minn
	k = int(math.ceil((maxx - minn) / 2))
	print(max(k, n_maxx), k + minn)


def max_diff(a, mid):
	for i in range(len(a)):
		if a[i] == -1:
			a[i] = mid
	max_dif = 0
	for i in range(len(a) - 1):
		max_dif = max(max_dif, abs(a[i] - a[i + 1]))
	return max_dif
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = 0
	r = 10 ** 9
	while l < r:
		mid = (l + r) // 2
		max_dif = max_diff(a[:], mid)
		prev = max_diff(a[:], mid - 1)
		next = max_diff(a[:], mid + 1)
		if max_dif <= prev and max_dif <= next:
			l = r = mid
		elif prev < max_dif:
			r = mid - 1
		else:
			l = mid + 1
	print(max_diff(a[:], r), r)


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)


for morzer in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	(maxo, max1, min1) = (0, 0, 1e+20)
	for i in range(1, n):
		if arr[i] != -1 and arr[i - 1] != -1:
			maxo = max(abs(arr[i] - arr[i - 1]), maxo)
		elif arr[i] != -1 and arr[i - 1] == -1:
			max1 = max(arr[i], max1)
			min1 = min(arr[i], min1)
		elif arr[i] == -1 and arr[i - 1] != -1:
			max1 = max(arr[i - 1], max1)
			min1 = min(arr[i - 1], min1)
	if min1 == 1e+20:
		print(0, 0)
	else:
		print(max(maxo, (max1 - min1 + 1) // 2), min1 + (max1 - min1 + 1) // 2)


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 sys
input = lambda : sys.stdin.readline().rstrip()
T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) for a in input().split()]
	mi = 10 ** 10
	ma = 0
	mama = 0
	for i in range(N - 1):
		if A[i] == -1 and A[i + 1] >= 0:
			mi = min(mi, A[i + 1])
			ma = max(ma, A[i + 1])
		elif A[i + 1] == -1 and A[i] >= 0:
			mi = min(mi, A[i])
			ma = max(ma, A[i])
		elif A[i] >= 0 and A[i + 1] >= 0:
			mama = max(mama, abs(A[i] - A[i + 1]))
	if mi > ma:
		print(mama, 1)
	else:
		print(max((ma - mi + 1) // 2, mama), (mi + ma) // 2)


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)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	arr = []
	for i in range(n):
		if a[i] != -1 and (i >= 1 and a[i - 1] == -1 or (i < n - 1 and a[i + 1] == -1)):
			arr.append(a[i])
	if len(arr) == 0:
		print(0, 1)
		continue
	val = (min(arr) + max(arr)) // 2
	mx = -1
	for i in range(n - 1):
		if a[i] != -1 and a[i + 1] != -1:
			mx = max(abs(a[i] - a[i + 1]), mx)
	aa = abs(val - arr[0])
	for i in range(len(arr)):
		aa = max(aa, abs(arr[i] - val))
	print(max(aa, mx), val)


t = int(input())
for q in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	maxd = 0
	mind = 1000000000
	m = 0
	countneg1 = 0
	countother = 0
	for x in range(n):
		if x != n - 1 and a[x] != -1 and (a[x + 1] != -1) and (abs(a[x] - a[x + 1]) > m):
			m = abs(a[x] - a[x + 1])
		if a[x] == -1:
			countneg1 += 1
		else:
			countother += 1
		if x != n - 1 and a[x] == -1 and (a[x + 1] != -1):
			if maxd < a[x + 1]:
				maxd = a[x + 1]
			if mind > a[x + 1]:
				mind = a[x + 1]
		if a[x] == -1 and a[x - 1] != -1 and (x != 0):
			if a[x - 1] > maxd:
				maxd = a[x - 1]
			if a[x - 1] < mind:
				mind = a[x - 1]
	if countother == 0:
		print(0, 1)
		continue
	diff = maxd - mind
	rtn = mind + (maxd - mind) // 2
	print(max(max(rtn - mind, maxd - rtn), m), rtn)


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)


import sys
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = []
	for i in range(n):
		if a[i] == -1:
			if i != 0 and a[i - 1] != -1:
				x.append(a[i - 1])
			if i != n - 1 and a[i + 1] != -1:
				x.append(a[i + 1])
	if not x:
		k1 = k2 = 0
	else:
		k1 = (max(x) + min(x)) // 2
		k2 = (max(x) + min(x) + 1) // 2
	res1 = 0
	res2 = 0
	for i in range(n - 1):
		t = a[i]
		t2 = a[i + 1]
		if t == -1:
			t = k1
		if t2 == -1:
			t2 = k1
		res1 = max(res1, abs(t - t2))
		t = a[i]
		t2 = a[i + 1]
		if t == -1:
			t = k2
		if t2 == -1:
			t2 = k2
		res2 = max(res2, abs(t - t2))
	if res1 < res2:
		print(res1, k1)
	else:
		print(res2, k2)


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)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	ans = 0
	for i in range(n):
		if i:
			if a[i] != -1 and a[i - 1] != -1:
				ans = max(abs(a[i] - a[i - 1]), ans)
		if a[i] == -1:
			if i 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 not b:
		return print(0, 1)
	ma = max(b)
	mi = min(b)
	s = (ma + mi) // 2
	print(max(ma - s, s - mi, ans), s)
for i in range(int(input())):
	solve()


import math
q = int(input())
for _ in range(q):
	n = int(input())
	l = list(map(int, input().split()))
	s = 0
	k = 0
	maxx = -1
	minn = 10 ** 9 + 1
	for i in range(n):
		if i > 0 and l[i] == -1 and (l[i - 1] != -1):
			maxx = max(maxx, l[i - 1])
			minn = min(minn, l[i - 1])
		if i < n - 1 and l[i] == -1 and (l[i + 1] != -1):
			maxx = max(maxx, l[i + 1])
			minn = min(minn, l[i + 1])
	k = (maxx + minn) // 2
	for i in range(n):
		if l[i] == -1:
			l[i] = k
	maxx_diff = -1
	for i in range(n - 1):
		maxx_diff = max(maxx_diff, abs(l[i + 1] - l[i]))
	print(maxx_diff, 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)


def check(k, arr, n):
	m = 0
	a = arr.copy()
	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]))
	return m
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mn = int(1000000000.0)
	mx = 0
	for i in range(n):
		if a[i] == -1:
			if i > 0:
				if a[i - 1] != -1:
					mn = min(mn, a[i - 1])
					mx = max(mx, a[i - 1])
			if i < n - 1:
				if a[i + 1] != -1:
					mn = min(mn, a[i + 1])
					mx = max(mx, a[i + 1])
	print(check((mn + mx) // 2, a, n), (mn + mx) // 2)


import math
n = int(input())
for i in range(n):
	input()
	arr = list(map(int, input().split()))
	mn = 9999999999
	mx = -1
	mxres = -1
	for g in range(1, len(arr) - 1):
		if arr[g] == -1:
			continue
		if arr[g - 1] == -1 or arr[g + 1] == -1:
			mn = min(mn, arr[g])
			mx = max(mx, arr[g])
		if arr[g - 1] != -1:
			mxres = max(mxres, abs(arr[g] - arr[g - 1]))
		if arr[g + 1] != -1:
			mxres = max(mxres, abs(arr[g] - arr[g + 1]))
	if arr[0] != -1 and arr[1] == -1:
		mn = min(mn, arr[0])
		mx = max(mx, arr[0])
	if arr[-1] != -1 and arr[-2] == -1:
		mn = min(mn, arr[-1])
		mx = max(mx, arr[-1])
	if arr.count(-1) == len(arr):
		print(0, 0)
		continue
	print(max(mxres, math.ceil((mx - mn) / 2)), math.ceil((mn + mx) / 2))


v = int(input())
for l in range(v):
	min_ = 10 ** 9
	max_ = 0
	_ = input()
	s = [int(x) for x in input().split(' ')]
	for (i, p) in enumerate(s):
		if p == -1:
			if i - 1 >= 0:
				if s[i - 1] != -1:
					min_ = min([min_, s[i - 1]])
					max_ = max([max_, s[i - 1]])
			if i + 1 < len(s):
				if s[i + 1] != -1:
					min_ = min([min_, s[i + 1]])
					max_ = max([max_, s[i + 1]])
	k = (min_ + max_) // 2
	s = [x if x != -1 else k for x in s]
	max_2 = 0
	for (i, a) in enumerate(s):
		if i - 1 >= 0:
			max_2 = max([max_2, abs(a - s[i - 1])])
	print(max_2, 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 MinimalReplacement(data):
	boundr = []
	mindif = 0
	for index in range(len(data)):
		if index != 0 and data[index] != -1 and (data[index - 1] != -1) and (abs(data[index] - data[index - 1]) > mindif):
			mindif = abs(data[index] - data[index - 1])
		if index != 0 and data[index] == -1 and (data[index - 1] != -1):
			boundr.append(data[index - 1])
		if index != len(data) - 1 and data[index] == -1 and (data[index + 1] != -1):
			boundr.append(data[index + 1])
	if boundr:
		return (max(mindif, (max(boundr) - min(boundr) + 1) // 2), (max(boundr) + min(boundr)) // 2)
	else:
		return (mindif, 0)
tests = int(input())
for i in range(tests):
	trash = input()
	data = list(map(int, input().split()))
	(d, k) = MinimalReplacement(data)
	print(d, ' ', k)


import math
t = int(input())
for i2 in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	(ma, small, big) = (0, 10 ** 9 + 1, -2)
	for i in range(n):
		if i > 0 and x[i] != -1 and (x[i - 1] != -1):
			ma = max(ma, abs(x[i] - x[i - 1]))
		if x[i] != -1 and (i > 0 and x[i - 1] == -1 or (i < n - 1 and x[i + 1] == -1)):
			big = max(big, x[i])
			small = min(small, x[i])
	print(max(ma, big - math.floor((big + small) / 2)), math.floor((big + small) / 2))


import math
t = int(input())
for tt in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	start = 0
	end = int(1000000000.0)
	mm = 1000000000.0
	anss = -1
	while start <= end:
		mid = (start + end) // 2
		mid1 = mid - 1
		mid2 = mid + 1
		ans = -1
		for i in range(1, n):
			a = arr[i - 1]
			b = arr[i]
			if a == -1:
				a = mid
			if b == -1:
				b = mid
			ans = max(ans, abs(a - b))
		ans1 = 0
		for i in range(1, n):
			a = arr[i - 1]
			b = arr[i]
			if a == -1:
				a = mid1
			if b == -1:
				b = mid1
			ans1 = max(ans1, abs(a - b))
		ans2 = -1
		for i in range(1, n):
			a = arr[i - 1]
			b = arr[i]
			if a == -1:
				a = mid2
			if b == -1:
				b = mid2
			ans2 = max(ans2, abs(a - b))
		if ans1 == -1:
			ans1 = int(1000000000000000.0)
		if ans2 == -1:
			ans2 = int(1000000000000000.0)
		if ans == -1:
			ans = int(1000000000000000.0)
		if mm > ans:
			mm = ans
			anss = mid
		if mm > ans1:
			mm = ans1
			anss = mid1
		if mm > ans2:
			mm = ans2
			anss = mid2
		if ans2 < ans1:
			start = mid + 1
		else:
			end = mid - 1
	print(mm, anss)


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


import math
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	temp = sorted(arr)
	if all((x == -1 for x in arr)):
		print('0 1')
		continue
	pairs = []
	for i in range(n):
		if arr[i] == -1:
			if i - 1 >= 0 and arr[i - 1] != -1:
				pairs.append(arr[i - 1])
			if i + 1 < n and arr[i + 1] != -1:
				pairs.append(arr[i + 1])
	mn = min(pairs)
	mx = max(pairs)
	val = (mn + mx) // 2
	for i in range(n):
		if arr[i] == -1:
			arr[i] = val
	mn = 0
	for i in range(n - 1):
		mn = max(mn, abs(arr[i] - arr[i + 1]))
	print(mn, end=' ')
	print(val)


def check(l, x):
	ans = 0
	for i in l:
		ans = max(ans, abs(i - x))
	return ans
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	minc = a.count(-1)
	if minc == n:
		print(0, 0)
	else:
		l = []
		for i in range(n):
			if i == 0:
				if a[i] != -1 and a[i + 1] == -1:
					l.append(a[i])
			elif i == n - 1:
				if a[i] != -1 and a[i - 1] == -1:
					l.append(a[i])
			elif a[i] != -1:
				if a[i + 1] == -1:
					l.append(a[i])
				if a[i - 1] == -1:
					l.append(a[i])
		l = list(set(l))
		l = sorted(l)
		ans = 0
		low = 0
		high = 10 ** 10
		while low <= high:
			mid = (low + high) // 2
			cm = check(l, mid)
			cl = check(l, mid - 1)
			cr = check(l, mid + 1)
			if cm <= cl and cm <= cr:
				ans = mid
				break
			elif cm <= cl and cm >= cr:
				low = mid + 1
			else:
				high = mid - 1
		b = []
		for i in a:
			if i != -1:
				b.append(i)
			else:
				b.append(ans)
		val = 0
		for i in range(1, n):
			val = max(val, abs(b[i] - b[i - 1]))
		print(val, ans)


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)


from sys import stdin, stdout
import math
q = int(stdin.readline())
for x in range(q):
	z = int(stdin.readline())
	a = [int(b) for b in stdin.readline().split()]
	dif = 0
	for each in range(len(a) - 1):
		temp = abs(a[each + 1] - a[each])
		if a[each] != -1 and a[each + 1] != -1:
			if temp > dif:
				dif = temp
	exist1 = []
	for i in range(len(a)):
		if i == 0:
			if a[i] != -1 and a[i + 1] == -1:
				exist1.append(a[i])
		elif i == len(a) - 1:
			if a[i] != -1 and a[i - 1] == -1:
				exist1.append(a[i])
		elif a[i] != -1 and (a[i - 1] == -1 or a[i + 1] == -1):
			exist1.append(a[i])
	exist1.sort()
	if not len(exist1) == 0:
		m = math.ceil((exist1[-1] - exist1[0]) / 2)
		k = m + exist1[0]
	else:
		k = 0
		m = 0
	if dif > m:
		m = dif
	print(m, k)


import math
import sys
for i 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])
			if i + 1 < n and a[i + 1] == -1:
				d.append(a[i])
	l = len(d)
	if l == 0:
		print(0, 1)
	else:
		s = min(d) + max(d)
		k1 = math.floor(s / 2)
		k2 = math.ceil(s / 2)
		m = 0
		for i in range(1, n):
			if a[i] == -1 and a[i - 1] == -1:
				m = max(m, 0)
			elif a[i - 1] == -1:
				m = max(m, abs(a[i] - k1))
			elif a[i] == -1:
				m = max(m, abs(a[i - 1] - k1))
			else:
				m = max(m, abs(a[i] - a[i - 1]))
		m1 = 0
		for i in range(1, n):
			if a[i] == -1 and a[i - 1] == -1:
				m1 = max(m1, 0)
			elif a[i - 1] == -1:
				m1 = max(m1, abs(a[i] - k2))
			elif a[i] == -1:
				m1 = max(m1, abs(a[i - 1] - k2))
			else:
				m1 = max(m1, abs(a[i] - a[i - 1]))
		if m < m1:
			print(m, k1)
		else:
			print(m1, k2)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	temp = []
	for i in range(n):
		if l[i] == -1:
			if i == 0:
				if l[i + 1] != -1:
					temp.append(l[i + 1])
			elif i == n - 1:
				if l[i - 1] != -1:
					temp.append(l[i - 1])
			else:
				if l[i - 1] != -1:
					temp.append(l[i - 1])
				if l[i + 1] != -1:
					temp.append(l[i + 1])
	temp = list(set(temp))
	temp.sort()
	if len(temp) == 0:
		k = 42
	else:
		k = (temp[0] + temp[-1]) // 2
	l_ = [0] * n
	for i in range(n):
		if l[i] == -1:
			l_[i] = k
		else:
			l_[i] = l[i]
	m = 0
	for i in range(n - 1):
		m = max(m, abs(l_[i + 1] - l_[i]))
	print(m, 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')


for tc in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if l.count(-1) == n:
		print(0, 1)
		continue
	mi = 10 ** 9 + 7
	ma = -100
	for i in range(n - 1):
		if l[i] == -1:
			if l[i + 1] != -1:
				if mi > l[i + 1]:
					mi = l[i + 1]
				if ma < l[i + 1]:
					ma = l[i + 1]
		elif l[i + 1] == -1:
			if mi > l[i]:
				mi = l[i]
			if ma < l[i]:
				ma = l[i]
	di = (ma + mi) // 2
	for i in range(n):
		if l[i] == -1:
			l[i] = di
	ans = -100
	for i in range(n - 1):
		if abs(l[i] - l[i + 1]) > ans:
			ans = abs(l[i] - l[i + 1])
	print(ans, di)


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)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	adj = []
	for i in range(0, len(arr)):
		if arr[i] != -1:
			if i - 1 >= 0 and arr[i - 1] == -1:
				adj.append(arr[i])
			if i + 1 < len(arr) and arr[i + 1] == -1:
				adj.append(arr[i])
	if len(adj) > 0:
		mi = min(adj)
		ma = max(adj)
		k = (mi + ma) // 2
		mm = 0
		for i in range(0, len(arr) - 1):
			if arr[i] == -1:
				arr[i] = k
			if arr[i + 1] == -1:
				arr[i + 1] = k
			mm = max(mm, abs(arr[i + 1] - arr[i]))
		print(' '.join([str(mm), str(k)]))
	else:
		print(' '.join([str(0), str(1)]))


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)


def main():
	n = int(input())
	a = list(map(int, input().split()))
	add = 0
	mx = -5
	mn = 1000000001
	cnt = 0
	for i in range(n):
		if i > 0 and a[i - 1] == -1 and (a[i] != -1):
			if a[i] > mx:
				mx = a[i]
			if a[i] < mn:
				mn = a[i]
		elif i < n - 1 and a[i + 1] == -1 and (a[i] != -1):
			if a[i] > mx:
				mx = a[i]
			if a[i] < mn:
				mn = a[i]
	avg = (mx + mn) // 2
	ans = -1
	for i in range(1, n):
		if a[i - 1] == -1:
			a[i - 1] = avg
		if a[i] == -1:
			a[i] = avg
		ans = max(ans, abs(a[i] - a[i - 1]))
	print(ans, avg)
	return

def test():
	t = int(input())
	while t:
		main()
		t -= 1
test()


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)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	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):
				l.append(a[i])
	s = sum(l)
	if len(l) > 0:
		avg = (max(l) + min(l)) // 2
	else:
		avg = 5
	for i in range(n):
		if a[i] == -1:
			a[i] = avg
	diff = 0
	for i in range(n - 1):
		diff = max(diff, abs(a[i + 1] - a[i]))
	print(diff, avg)


from math import inf

def main():
	for _ in range(int(input())):
		n = int(input())
		gifts = list(map(int, input().split(' ')))
		checker_list = []
		for i in range(len(gifts)):
			if i == 0:
				if gifts[i] != -1 and gifts[i + 1] == -1:
					checker_list.append(gifts[i])
			elif i == len(gifts) - 1:
				if gifts[i] != -1 and gifts[i - 1] == -1:
					checker_list.append(gifts[i])
			elif gifts[i] != -1 and (gifts[i + 1] == -1 or gifts[i - 1] == -1):
				checker_list.append(gifts[i])
		if checker_list:
			mn = min(checker_list)
			mx = max(checker_list)
			k = (mx + mn) // 2
			for i in range(len(gifts)):
				if gifts[i] == -1:
					gifts[i] = k
			diff_list = []
			for i in range(len(gifts) - 1):
				diff_list.append(abs(gifts[i] - gifts[i + 1]))
			max_diff = max(diff_list)
			print(max_diff, k)
		else:
			print(0, 1)
main()


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	n = ii()
	l = il()
	mx = -10 ** 10
	mn = 10 ** 10
	mxd = -10 ** 10
	for i in range(n - 1):
		if l[i + 1] != -1 and l[i] != -1:
			mxd = max(mxd, abs(l[i] - l[i + 1]))
		elif l[i] == -1 and l[i + 1] != -1:
			mx = max(mx, l[i + 1])
			mn = min(mn, l[i + 1])
		elif l[i] != -1 and l[i + 1] == -1:
			mx = max(mx, l[i])
			mn = min(mn, l[i])
	if mxd == -10 ** 10:
		if mx == -10 ** 10 and mn == 10 ** 10:
			print(0, 1)
		else:
			print((mx - mn + 1) // 2, (mx - mn + 1) // 2 + mn)
	else:
		x = max(mxd, (mx - mn + 1) // 2)
		print(x, mn + x)


n = int(input())
for i in range(n):
	t = int(input())
	l = input().split()
	for j in range(t):
		l[j] = int(l[j])
	maxx = -1
	minn = 1000000000
	for j in range(t):
		if j != 0 and j != t - 1:
			if l[j] != -1 and (l[j - 1] == -1 or l[j + 1] == -1):
				if l[j] < minn:
					minn = l[j]
				if l[j] > maxx:
					maxx = l[j]
		elif j == 0:
			if l[j] != -1 and l[j + 1] == -1:
				if l[j] < minn:
					minn = l[j]
				if l[j] > maxx:
					maxx = l[j]
		elif l[j] != -1 and l[j - 1] == -1:
			if l[j] < minn:
				minn = l[j]
			if l[j] > maxx:
				maxx = l[j]
	k = int((maxx + minn) / 2)
	maxx = 0
	for j in range(t - 1):
		if l[j] == -1:
			l[j] = k
		if l[j + 1] == -1:
			l[j + 1] = k
		if abs(l[j] - l[j + 1]) > maxx:
			maxx = abs(l[j] - l[j + 1])
	print(maxx, end=' ')
	print(k)


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	stable_max = 0
	max_val = -1
	min_val = 10 ** 9
	for i in range(len(a) - 1):
		if (a[i] == -1) ^ (a[i + 1] == -1):
			num = max(a[i], a[i + 1])
			max_val = max(max_val, num)
			min_val = min(min_val, num)
		if a[i] != -1 and a[i + 1] != -1:
			stable_max = max(stable_max, abs(a[i] - a[i + 1]))
	if max_val == -1:
		print(0, 1)
	else:
		ans = max_val + min_val
		ans //= 2
		diff = max(max_val - ans, ans - min_val, stable_max)
		print(diff, ans)


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)


import math

def mb(arr):
	negs = 0
	mini = math.inf
	maxi = -math.inf
	all_neg = True
	for i in range(len(arr) - 1):
		if arr[i] != -1 and arr[i + 1] == -1:
			mini = min(mini, arr[i])
			maxi = max(maxi, arr[i])
			all_neg = False
		if arr[i] == -1 and arr[i + 1] != -1:
			mini = min(arr[i + 1], mini)
			maxi = max(arr[i + 1], maxi)
			all_neg = False
	if all_neg:
		return (0, 42)
	avg = (mini + maxi) // 2
	min_tax = 0
	for i in range(len(arr) - 1):
		(l, r) = (arr[i], arr[i + 1])
		if l == -1:
			l = avg
		if r == -1:
			r = avg
		min_tax = max(abs(r - l), min_tax)
	return (min_tax, avg)
t = int(input())
for _t in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = mb(arr)
	print(str(ans[0]) + ' ' + str(ans[1]))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	k = 0
	m = -1
	p = 10 ** 9 + 7
	for i in range(n):
		if l[i] == -1:
			t = str(int(l[max(0, i - 1)] != -1)) + str(int(l[min(i + 1, n - 1)] != -1))
			if t == '11':
				m = max([m, l[i - 1], l[i + 1]])
				p = min([p, l[i - 1], l[i + 1]])
			elif t == '01':
				m = max(m, l[i + 1])
				p = min(p, l[i + 1])
			elif t == '10':
				m = max(m, l[i - 1])
				p = min(p, l[i - 1])
	k = (m + p) // 2
	m = 0
	for i in range(n - 1):
		if l[i] == -1:
			l[i] = k
		if l[i + 1] == -1:
			l[i + 1] = k
		if abs(l[i + 1] - l[i]) > m:
			m = abs(l[i + 1] - l[i])
	print(m, k)


import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

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

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	n = int(input())
	a = list(mapi())
	if n <= 2:
		if max(a) >= 0:
			print(0, max(a))
		else:
			print(0, 42)
		continue
	mx = max(a)
	if mx == -1:
		mx = 0
	for i in range(n):
		if a[i] != -1:
			mx = min(mx, a[i])
	l = 0
	r = int(1000000000.0)

	def check(mid):
		mn = int(1000000000.0)
		mx = 0
		for i in range(n - 1):
			if a[i] == -1 and a[i + 1] == -1:
				continue
			if a[i] == -1 or a[i + 1] == -1:
				mn = min(mn, max(a[i], a[i + 1]) + mid)
				mx = max(mx, max(a[i], a[i + 1]) - mid)
		return (mn >= mx, mx)
	l = 0
	for i in range(n - 1):
		if a[i] != -1 and a[i + 1] != -1:
			l = max(l, abs(a[i] - a[i + 1]))
	ans = float('inf')
	while r - l > 0:
		mid = l + r >> 1
		(x, tmp) = check(mid)
		if x:
			ans = tmp
			r = mid
		else:
			l = mid + 1
	print(r, ans)


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)


t = int(input())
for T in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if max(a) == -1:
		print(0, 79)
		continue
	mi = max(a)
	ma = 0
	for i in range(n):
		if a[i] == -1:
			if i > 0 and a[i - 1] != -1:
				mi = min(mi, a[i - 1])
				ma = max(ma, a[i - 1])
			if i < n - 1 and a[i + 1] != -1:
				mi = min(mi, a[i + 1])
				ma = max(ma, a[i + 1])
	k = (ma + mi) // 2
	a = [k if i == -1 else i for i in a]
	m = max([abs(a[i - 1] - a[i]) for i in range(1, n)])
	print(m, k)


for _ in range(int(input())):
	n = int(input())
	array = list(map(int, input().split()))
	this = []
	i = 0
	for i in range(n):
		if array[i] == -1:
			continue
		if i - 1 >= 0:
			if array[i - 1] == -1:
				this.append(array[i])
				continue
		if i + 1 < n:
			if array[i + 1] == -1:
				this.append(array[i])
				continue
	this = list(set(this))
	if len(this) == 0:
		print(*[0, 5])
		continue
	ans = (min(this) + max(this)) // 2
	sumo = -1
	for i in range(n - 1):
		if array[i] == -1:
			array[i] = ans
		if array[i + 1] == -1:
			array[i + 1] = ans
		sumo = max(sumo, abs(array[i] - array[i + 1]))
	print(*[sumo, ans])


import math
t = int(input())
while t:
	t += -1
	n = int(input())
	l = list(map(int, input().split()))
	arr = []
	check = 0
	for i in l:
		if i != -1:
			check = 1
	if check == 0:
		print('0 1')
	else:
		for i in range(n):
			if l[i] == -1:
				if i == 0:
					if l[1] != -1:
						arr.append(l[1])
				elif i == n - 1:
					if l[n - 2] != -1:
						arr.append(l[n - 2])
				else:
					if l[i - 1] != -1:
						arr.append(l[i - 1])
					if l[i + 1] != -1:
						arr.append(l[i + 1])
		arr = list(set(arr))
		arr.sort()
		avg = math.ceil((arr[0] + arr[len(arr) - 1]) / 2)
		l2 = []
		for i in l:
			if i != -1:
				l2.append(i)
			else:
				l2.append(avg)
		mx1 = 0
		for i in range(n - 1):
			if abs(l2[i] - l2[i + 1]) > mx1:
				mx1 = abs(l2[i] - l2[i + 1])
		mx2 = 0
		avg += -1
		l2 = []
		for i in l:
			if i != -1:
				l2.append(i)
			else:
				l2.append(avg)
		for i in range(n - 1):
			if abs(l2[i] - l2[i + 1]) > mx2:
				mx2 = abs(l2[i] - l2[i + 1])
		if mx2 < mx1:
			print(mx2, avg)
		else:
			print(mx1, avg + 1)


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)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

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

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		a = LI()
		if set(a) == 1:
			rr.append('0 1')
			continue
		l = inf
		r = 0
		for (b, c) in zip(a, a[1:]):
			if c < b:
				(b, c) = (c, b)
			if b != -1 or c == -1:
				continue
			l = min(c, l)
			r = max(c, r)
		if l == inf:
			l = 10
		t = (l + r) // 2
		for i in range(n):
			if a[i] < 0:
				a[i] = t
		s = 0
		for (b, c) in zip(a, a[1:]):
			u = abs(b - c)
			if s < u:
				s = u
		rr.append(JA([s, t], ' '))
	return JA(rr, '\n')
print(main())


t = int(input())
for T in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if a == [-1] * len(a):
		print(0, 1)
		continue
	mi = 10 ** 9 + 1
	ma = -1
	if n == 1:
		print(0, a[0])
		continue
	for i in range(len(a)):
		if a[i] != -1:
			if i > 0:
				if a[i - 1] == -1:
					mi = min([mi, a[i]])
					ma = max([ma, a[i]])
			if i < len(a) - 1:
				if a[i + 1] == -1:
					mi = min([mi, a[i]])
					ma = max([ma, a[i]])
	k = (mi + ma) // 2
	for i in range(len(a)):
		if a[i] == -1:
			a[i] = k
	m = 0
	for i in range(len(a) - 1):
		m = max(m, abs(a[i] - a[i + 1]))
	print(m, 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()))
	ans = []
	for i in range(len(a)):
		if a[i] == -1:
			if i > 0 and a[i - 1] != -1:
				ans.append(a[i - 1])
			if i < n - 1 and a[i + 1] != -1:
				ans.append(a[i + 1])
	if len(ans) == 0:
		amin = 1
		amax = 1
	else:
		amin = min(ans)
		amax = max(ans)
	k = (amin + amax) // 2
	m = 0
	for i in range(1, len(a)):
		if a[i - 1] == -1:
			a[i - 1] = k
		if a[i] == -1:
			a[i] = k
		m = max(m, abs(a[i] - a[i - 1]))
	print(m, k)


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


from math import ceil
t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	mn = float('-inf')
	m = set()
	for (index, j) in enumerate(ar):
		if j == -1:
			if index != 0:
				if ar[index - 1] != -1:
					m.add(ar[index - 1])
			if index != n - 1:
				if ar[index + 1] != -1:
					m.add(ar[index + 1])
	if m:
		ans = ceil((min(m) + max(m)) / 2)
	else:
		ans = 42
	for index in range(n):
		if index != 0:
			if ar[index] == -1:
				ar[index] = ans
			if ar[index - 1] == -1:
				ar[index - 1] = ans
			d = abs(ar[index] - ar[index - 1])
			if d > mn:
				mn = d
	print(mn, ans)


from math import ceil, sqrt, gcd

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

def si():
	return input()

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

def li():
	return list(mi())
t = ii()
while t:
	t -= 1
	n = ii()
	a = li()
	x = 1000000000.0
	y = 0
	f = 0
	for i in range(n):
		if a[i] == -1:
			if i > 0:
				if a[i - 1] != -1:
					f = 1
					x = min(x, a[i - 1])
					y = max(y, a[i - 1])
			if i < n - 1:
				if a[i + 1] != -1:
					f = 1
					x = min(x, a[i + 1])
					y = max(y, a[i + 1])
	if f == 0:
		print(0, 1)
	else:
		s = x + (y - x) // 2
		for i in range(n):
			if a[i] == -1:
				a[i] = s
		x = 0
		for i in range(1, n):
			x = max(x, abs(a[i] - a[i - 1]))
		print(x, s)


def calc(u):
	global n, a
	ans = 0
	for i in range(n - 1):
		x = a[i]
		y = a[i + 1]
		if x == -1:
			x = u
		if y == -1:
			y = u
		ans = max(ans, abs(x - y))
	return ans

def check(u):
	return calc(u + 1) - calc(u)

def solve():
	global n, a
	n = int(input())
	a = list(map(int, input().split()))
	(l, r) = (0, 10 ** 9 + 1)
	if check(l) >= 0:
		print(calc(0), 0)
		return
	while r - l > 1:
		mid = (l + r) // 2
		if check(l) * check(mid) > 0:
			l = mid
		else:
			r = mid
	print(*min(((calc(i), i) for i in range(max(0, l - 2), min(10 ** 9, l + 2)))))
t = int(input())
for _ in range(t):
	solve()


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


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


t = int(input())
while t:
	n = int(input())
	a = input().split()
	maxi = -1
	mini = 10 ** 9 + 1
	for i in range(n):
		if int(a[i]) == -1:
			if i - 1 >= 0:
				if int(a[i - 1]) != -1:
					mini = min(mini, int(a[i - 1]))
					maxi = max(maxi, int(a[i - 1]))
			if i + 1 <= n - 1:
				if int(a[i + 1]) != -1:
					mini = min(mini, int(a[i + 1]))
					maxi = max(maxi, int(a[i + 1]))
	if True:
		for i in range(n):
			a[i] = int(a[i])
			if a[i] == -1:
				a[i] = (maxi + mini) // 2
		lol = 0
		for i in range(1, n):
			lol = max(lol, abs(a[i] - a[i - 1]))
		print(lol, (maxi + mini) // 2)
	t -= 1


import math
cases = int(input())
for case in range(cases):
	n = int(input())
	l = [int(i) for i in input().split()]
	borders = []
	max_natural_abs_diff = 0
	for i in range(len(l)):
		if i < len(l) - 1:
			if l[i] != -1 and l[i + 1] != -1:
				max_natural_abs_diff = max(max_natural_abs_diff, abs(l[i] - l[i + 1]))
		if l[i] == -1:
			if i > 0 and l[i - 1] != -1:
				borders.append(l[i - 1])
			if i < n - 1 and l[i + 1] != -1:
				borders.append(l[i + 1])
	if len(borders) == 0:
		print(str(max_natural_abs_diff) + ' 42')
	else:
		k = math.floor(max(borders) / 2 + min(borders) / 2)
		m = max(max_natural_abs_diff, max(borders) - k)
		print(str(m) + ' ' + str(k))


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	a = I()
	b = set()
	init = 0
	for i in range(n):
		if i > 0 and a[i] >= 0 and (a[i - 1] >= 0):
			init = max(init, abs(a[i] - a[i - 1]))
		if a[i] == -1:
			if i - 1 >= 0 and a[i - 1] >= 0:
				b.add(a[i - 1])
			if i + 1 < n and a[i + 1] >= 0:
				b.add(a[i + 1])
	b = list(b)
	if not b:
		print(0, 1)
	else:
		mx = max(b)
		mn = min(b)
		ans = (min(b) + max(b)) // 2
		print(max(init, ans - mn, mx - ans), ans)


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, itertools, math
T = int(sys.stdin.readline())
for _ in range(T):
	A = sys.stdin.readline().strip()
	N = [int(i) for i in sys.stdin.readline().strip().split(' ')]
	maxn = -1
	minn = 10 ** 9
	for i in range(len(N)):
		if i < len(N) - 1 and N[i] == -1 and (N[i + 1] != -1):
			maxn = max(maxn, N[i + 1])
			minn = min(minn, N[i + 1])
		if i > 0 and N[i] == -1 and (N[i - 1] != -1):
			maxn = max(maxn, N[i - 1])
			minn = min(minn, N[i - 1])
	k = (minn + maxn) // 2
	m = 0
	for i in range(len(N)):
		if N[i] == -1:
			N[i] = k
		if i > 0:
			m = max(m, abs(N[i] - N[i - 1]))
	print(m, k)


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)


tcases = int(input())
for i in range(tcases):
	alen = int(input())
	a = [int(x) for x in input().split(' ')]
	max_ = -1000000010
	min_ = 1000000010
	for i in range(alen):
		if a[i] == -1:
			if i > 0:
				if a[i - 1] != -1:
					max_ = max(max_, a[i - 1])
					min_ = min(min_, a[i - 1])
			if i < alen - 1:
				if a[i + 1] != -1:
					max_ = max(max_, a[i + 1])
					min_ = min(min_, a[i + 1])
	k = (max_ + min_) // 2
	a = [x if x != -1 else k for x in a]
	m = 0
	for i in range(alen - 1):
		m = max(m, abs(a[i] - a[i + 1]))
	print(m, ' ', k)


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


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


import sys
from sys import stdin, stdout
import bisect
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

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

def sin():
	return input()

def inin():
	return int(input())
import math

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

def main():
	t = inin()
	for _ in range(t):
		n = inin()
		a = ain()
		b = []
		for i in range(n):
			if a[i] == -1:
				if i != 0:
					b.append(a[i - 1])
				if i != n - 1:
					b.append(a[i + 1])
		b = list(set(b))
		if -1 in b:
			b.remove(-1)
		if len(b) == 0:
			x = 1
		else:
			x = min(b) + max(b)
			x = x // 2
		ans = 0
		for i in range(1, n):
			if a[i] < 0:
				a[i] = x
			if a[i - 1] < 0:
				a[i - 1] = x
			ans = max(abs(a[i] - a[i - 1]), ans)
		print(ans, x)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


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)


def absolute(A, m):
	maxi = 0
	for i in range(1, len(A)):
		if A[i] >= 0:
			if A[i - 1] == -1:
				maxi = max(maxi, abs(A[i] - m))
			else:
				maxi = max(maxi, abs(A[i] - A[i - 1]))
		elif A[i - 1] >= 0:
			maxi = max(maxi, abs(A[i - 1] - m))
	return maxi

def answer(n, A):
	l = 0
	r = 10 ** 9
	ans = 10 ** 9
	k = 0
	while r >= l:
		mid = (l + r) // 2
		d1 = absolute(A, mid - 1)
		d2 = absolute(A, mid)
		d3 = absolute(A, mid + 1)
		if d2 < ans:
			ans = d2
			k = mid
		if d1 > d3:
			l = mid + 1
		else:
			r = mid - 1
	return [ans, k]
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(*answer(n, arr))


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)


from cmath import nan
from audioop import avg

def mad(x):
	m = 0
	for i in range(len(x) - 1):
		m = max(m, abs(x[i] - x[i + 1]))
	return m

def replace(arr, val):
	for i in range(len(arr)):
		if arr[i] == -1:
			arr[i] = val
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	smalldiff = float('inf')
	maxdiff = 0
	for i in range(len(arr)):
		if arr[i] == -1:
			if i != 0:
				if arr[i - 1] != -1:
					smalldiff = min(smalldiff, arr[i - 1])
					maxdiff = max(maxdiff, arr[i - 1])
			if i != len(arr) - 1:
				if arr[i + 1] != -1:
					smalldiff = min(smalldiff, arr[i + 1])
					maxdiff = max(maxdiff, arr[i + 1])
	avgdiff = (maxdiff + smalldiff) // 2
	if smalldiff > 10 ** 9:
		avgdiff = 0
	arr_org = arr.copy()
	replace(arr, avgdiff)
	replace(arr_org, avgdiff + 1)
	(m1, m2) = (mad(arr), mad(arr_org))
	if m1 < m2:
		print(m1, avgdiff)
	else:
		print(m2, avgdiff + 1)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mi = 10000000000
	ma = -1
	md = -1
	for i in range(len(a) - 1):
		(ai, ai1) = (a[i], a[i + 1])
		if ai == -1:
			if ai1 != -1:
				mi = min(ai1, mi)
				ma = max(ai1, ma)
		elif ai1 == -1:
			mi = min(ai, mi)
			ma = max(ai, ma)
		else:
			md = max(md, abs(ai - ai1))
	if ma == -1:
		print(0, 1)
	else:
		mia = (mi + ma) // 2
		print(max(ma - mia, mia - mi, md), mia)


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


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


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)


def calc(a, k):
	ret = 0
	prev = -1
	for i in a:
		if i == -1:
			if prev != -1:
				ret = max(ret, abs(k - prev))
			prev = k
		else:
			if prev != -1:
				ret = max(ret, abs(i - prev))
			prev = i
	return ret
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	(lb, ub) = (0, 10 ** 9)
	while ub - lb > 2:
		k1 = (2 * lb + ub) // 3
		k2 = (lb + 2 * ub) // 3
		m1 = calc(a, k1)
		m2 = calc(a, k2)
		if m1 == m2:
			(lb, ub) = (k1, k2)
		elif m1 < m2:
			ub = k2
		else:
			lb = k1
	mk = [(calc(a, k), k) for k in range(lb, ub + 1)]
	(m, k) = min(mk)
	print(m, k)


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():
	n = int(input())
	l = list(map(int, input().split()))
	ma = 0
	mi = 1000000000
	ma1 = 0
	for i in range(n):
		if l[i] == -1:
			if i - 1 >= 0 and l[i - 1] != -1:
				ma = max(ma, l[i - 1])
				mi = min(mi, l[i - 1])
			if i + 1 < n and l[i + 1] != -1:
				ma = max(ma, l[i + 1])
				mi = min(mi, l[i + 1])
	ma = (ma + mi) // 2
	ans = 0
	for i in range(n):
		if l[i] == -1:
			l[i] = ma
		if i:
			ans = max(ans, abs(l[i] - l[i - 1]))
	print(ans, ma)
t = int(input())
for _ in range(t):
	main()


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


import sys
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
for _ in range(int(input())):
	n = int(input())
	m1 = 10 ** 10
	m2 = -1
	diff = 0
	last = -1
	a = read()
	n1 = n - 1
	for (ind, i) in enumerate(a):
		if i >= 0 and last >= 0:
			diff = max(diff, abs(i - last))
		last = i
		if i >= 0 and (ind > 0 and a[ind - 1] == -1 or (ind < n1 and a[ind + 1] == -1)):
			if m1 > i:
				m1 = i
			if m2 < i:
				m2 = i
	if m1 == 10 ** 10 or m2 == -1:
		print(0, 23)
		continue
	k = (m1 + m2) // 2
	print(max(diff, m2 - k), k)


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)


import sys
import math as mt
input = sys.stdin.buffer.readline
t = int(input())
for __ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ch = []
	if l[0] != -1 and l[1] == -1:
		ch.append(l[0])
	for i in range(1, n - 1):
		if l[i - 1] == -1 and l[i] != -1 or (l[i + 1] == -1 and l[i] != -1):
			ch.append(l[i])
	if l[-1] == -1 and l[n - 2] != -1:
		ch.append(l[n - 2])
	if l[-1] != -1 and l[n - 2] == -1:
		ch.append(l[-1])
	ch = list(set(ch))
	ch.sort()
	k = 2
	if len(ch) == 1:
		k = ch[0]
	elif len(ch) > 1:
		k = (ch[0] + ch[-1]) // 2
	maxi = 0
	for i in range(n):
		if l[i] == -1:
			l[i] = k
	for i in range(1, n):
		maxi = max(maxi, abs(l[i - 1] - l[i]))
	print(maxi, k)


T = int(input(), 10)
for i in range(T):
	n = int(input(), 10)
	arr = input()
	arr = arr.split(' ')
	for i in range(len(arr)):
		arr[i] = int(arr[i], 10)
	j = 1
	mini = float('inf')
	maxi = 0
	if arr[0] != -1 and arr[1] == -1:
		mini = min(mini, arr[0])
		maxi = max(maxi, arr[0])
	if arr[n - 1] != -1 and arr[n - 2] == -1:
		mini = min(mini, arr[n - 1])
		maxi = max(maxi, arr[n - 1])
	while j < n - 1:
		if arr[j] != -1 and (arr[j - 1] == -1 or arr[j + 1] == -1):
			mini = min(mini, arr[j])
			maxi = max(maxi, arr[j])
		j += 1
	if mini == float('inf'):
		print(0, 69)
		continue
	avg = (maxi + mini) // 2
	for i in range(len(arr)):
		if arr[i] == -1:
			arr[i] = avg
	ans = 0
	for i in range(n - 1):
		ans = max(ans, abs(arr[i] - arr[i + 1]))
	print(ans, avg)


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
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if a == [-1] * n:
		print(0, 1)
		continue
	l = []
	for i in range(n):
		if a[i] == -1:
			continue
		if i == 0:
			if a[i + 1] == -1:
				l.append(a[i])
		elif i == n - 1:
			if a[i - 1] == -1:
				l.append(a[i])
		elif a[i - 1] == -1 or a[i + 1] == -1:
			l.append(a[i])
	l.sort()
	k = (l[0] + l[-1]) // 2
	m = -1
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(n - 1):
		m = max(m, abs(a[i] - a[i + 1]))
	print(m, k)


t = int(input())
for kek in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mi = 10 ** 9
	ma = 0
	sosed = set()
	k = 777
	for i in range(n):
		if a[i] == -1:
			if i + 1 < n:
				if a[i + 1] != -1:
					sosed.add(a[i + 1])
			if i - 1 >= 0:
				if a[i - 1] != -1:
					sosed.add(a[i - 1])
	if len(sosed) != 0:
		k = (min(sosed) + max(sosed)) // 2
	if k == -1:
		k = 777
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	ans = 0
	for i in range(1, n):
		ans = max(ans, abs(a[i] - a[i - 1]))
	print(ans, 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)


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


n = int(input())
for _ in range(n):
	input()
	nums = list(map(int, input().split()))
	(minn, maxx) = (10000000000, 0)
	for i in range(len(nums)):
		if i == 0:
			if nums[i] != -1 and nums[i + 1] == -1:
				minn = min(minn, nums[i])
				maxx = max(maxx, nums[i])
		elif i == len(nums) - 1:
			if nums[i] != -1 and nums[i - 1] == -1:
				minn = min(minn, nums[i])
				maxx = max(maxx, nums[i])
		elif nums[i] != -1 and (nums[i + 1] == -1 or nums[i - 1] == -1):
			minn = min(minn, nums[i])
			maxx = max(maxx, nums[i])
	if minn == 10000000000:
		print(0, end=' ')
		print(1)
		continue
	rep = (minn + maxx) // 2
	res = 0
	for i in range(len(nums)):
		if nums[i] == -1:
			nums[i] = rep
		if i:
			res = max(res, abs(nums[i] - nums[i - 1]))
	print(res, end=' ')
	print(rep)


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	diff_already = 0
	(baga, ih) = (1 << 32, 0)
	for i in range(n):
		if a[i] == -1:
			if i != 0:
				if a[i - 1] != -1:
					baga = min(baga, a[i - 1])
					ih = max(ih, a[i - 1])
			if i != n - 1:
				if a[i + 1] != -1:
					ih = max(ih, a[i + 1])
					baga = min(baga, a[i + 1])
		if a[i] == -1:
			continue
		if i == n - 1:
			continue
		if a[i + 1] == -1:
			continue
		diff_already = max(diff_already, abs(a[i] - a[i + 1]))
	if baga == 1 << 32:
		print('0 0')
	else:
		k = (baga + ih + 1) // 2
		m = k - baga
		print(max(diff_already, m), 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())
	arr = list(map(int, input().split()))
	m = 0
	for i in range(1, n):
		if arr[i] != -1 and arr[i - 1] != -1:
			m = max(m, abs(arr[i] - arr[i - 1]))
	maxx = 0
	minn = 10 ** 9
	for i in range(1, n - 1):
		if arr[i] == -1:
			if arr[i - 1] != -1:
				maxx = max(maxx, arr[i - 1])
				minn = min(minn, arr[i - 1])
			if arr[i + 1] != -1:
				maxx = max(maxx, arr[i + 1])
				minn = min(minn, arr[i + 1])
	if arr[0] == -1:
		if arr[1] != -1:
			maxx = max(maxx, arr[1])
			minn = min(minn, arr[1])
	if arr[-1] == -1:
		if arr[-2] != -1:
			maxx = max(maxx, arr[-2])
			minn = min(minn, arr[-2])
	if m == 0:
		if maxx == 0 and minn == 10 ** 9:
			print(0, 1)
		else:
			x = (maxx + minn) // 2
			print(max(maxx - x, x - minn), x)
	else:
		b = False
		x = (maxx + minn) // 2
		if max(maxx - x, x - minn) > m:
			print(max(maxx - x, x - minn), x)
		else:
			print(m, x)


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)


oo = 1000000010
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	mn = oo
	mx = -oo
	for i in range(n):
		if i > 0 and l[i] == -1 and (l[i - 1] != -1):
			mn = min(mn, l[i - 1])
			mx = max(mx, l[i - 1])
		if i < n - 1 and l[i] == -1 and (l[i + 1] != -1):
			mn = min(mn, l[i + 1])
			mx = max(mx, l[i + 1])
	k = (mx + mn) // 2
	m = 0
	for i in range(n):
		if l[i] == -1:
			l[i] = k
		if i:
			m = max(m, abs(l[i] - l[i - 1]))
	print(m, '', 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)


n = int(input())
for i in range(n):
	a = int(input())
	b = list(map(int, input().split()))
	mx = -100000000
	mn = 1000000000
	for i in range(a):
		if i > 0 and b[i] == -1 and (b[i - 1] != -1):
			mn = min(mn, b[i - 1])
			mx = max(mx, b[i - 1])
		if i < a - 1 and b[i] == -1 and (b[i + 1] != -1):
			mn = min(mn, b[i + 1])
			mx = max(mx, b[i + 1])
	h = mn
	m = mx
	l = (m + h) // 2
	for i in range(a):
		if b[i] == -1:
			b[i] = l
	diff = 0
	for i in range(1, a):
		if abs(b[i] - b[i - 1]) > diff:
			diff = abs(b[i] - b[i - 1])
	print(diff, l)


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


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if a.count(-1) == len(a):
		print(0, 1)
	else:
		d = list()
		for i in range(n):
			if i + 1 < n and a[i] == -1 and (a[i + 1] != -1):
				d.append(a[i + 1])
			if i - 1 >= 0 and a[i] == -1 and (a[i - 1] != -1):
				d.append(a[i - 1])
		m = 0
		for i in range(n - 1):
			if a[i] != -1 and a[i + 1] != -1:
				m = max(m, abs(a[i] - a[i + 1]))
		d.sort()
		s = d[-1] + d[0]
		if s % 2 == 0:
			k = s // 2
			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:
			t1 = s // 2
			t2 = t1 + 1
			v = a.copy()
			for i in range(n):
				if a[i] == -1:
					a[i] = t1
				if v[i] == -1:
					v[i] = t2
			q = m
			for i in range(1, n):
				m = max(m, abs(a[i] - a[i - 1]))
				q = max(q, abs(v[i] - v[i - 1]))
			if m < q:
				print(m, t1)
			else:
				print(q, t2)


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


t = int(input())
for ii in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	B = []
	ab = 0
	for i in range(n - 1):
		if A[i] == -1 and A[i + 1] != -1:
			B.append(A[i + 1])
		elif A[i] != -1 and A[i + 1] == -1:
			B.append(A[i])
		else:
			ab = max(ab, abs(A[i] - A[i + 1]))
	B.sort()
	b = 0
	ab2 = 0
	if len(B) > 0:
		b = (B[-1] - B[0] + 1) // 2 + B[0]
		ab2 = max(abs(B[-1] - b), abs(B[0] - b))
	print(max(ab, ab2), b)


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


def solution():
	from sys import stdin, stdout
	(_input, _print, _range, _int, _zip, _set, _len) = (stdin.readline, stdout.write, range, int, zip, set, len)
	(_min, _max, _str, _abs) = (min, max, str, abs)
	n = _int(_input())
	for _ in _range(n):
		l = _int(_input())
		arr = [_int(i) for i in _input().split()]
		maximum = -1
		minimum = 1000000000
		m = 0
		old = arr[0]
		f = True if arr[0] == -1 else False
		for i in arr[1:]:
			if i >= 0:
				f = False
			if i == -1 and old == -1:
				old = i
				continue
			if i == -1 and old != -1:
				if old > maximum:
					maximum = old
				if old < minimum:
					minimum = old
				old = i
				continue
			if i != -1 and old == -1:
				if i > maximum:
					maximum = i
				if i < minimum:
					minimum = i
				old = i
				continue
			_m = _abs(old - i)
			if m < _m:
				m = _m
			old = i
		if minimum != 1000000000 and maximum != -1:
			average = (maximum + minimum) // 2
			_m = _max(maximum - average, average - minimum)
			if m < _m:
				m = _m
		if f:
			_print('0 42\n')
		else:
			_print(_str(m) + ' ')
			_print(_str(average) + '\n')
solution()


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)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	mn = float('inf')
	mx = 0
	diff = 0
	k = None
	for i in range(n - 1):
		if arr[i] != -1 and arr[i + 1] != -1:
			diff = max(diff, abs(arr[i + 1] - arr[i]))
		elif arr[i] == -1 and arr[i + 1] == -1:
			continue
		elif arr[i] == -1:
			mx = max(mx, arr[i + 1])
			mn = min(mn, arr[i + 1])
		else:
			mx = max(mx, arr[i])
			mn = min(mn, arr[i])
	if mn == float('inf'):
		print(f'0 42')
	else:
		k = (mn + mx) // 2
		print(f'{max(abs(k - mn), abs(k - mx), diff)} {k}')


n = 0
l = []

def get(j):
	ans = 0
	p = [] + l
	for i in range(n):
		if p[i] == -1:
			p[i] = j
	for i in range(n):
		if i + 1 < n:
			ans = max(ans, p[i] - p[i + 1])
		if i - 1 >= 0:
			ans = max(ans, p[i] - p[i - 1])
	return [ans, j]

def search(l, r):
	ans = [10000000001, 10000000001]
	if r - l < 10:
		for i in range(l, r + 1):
			p = get(i)
			if p[0] < ans[0]:
				ans = p
		return ans
	mid = (l + r) // 2
	left = get(mid - 1)
	centre = get(mid)
	if left[0] < centre[0]:
		return search(l, mid - 1)
	return search(mid, r)
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = search(0, 1000000001)
	print(ans[0], ans[1])


from math import gcd
import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)
(t,) = map(int, input().split())
for _ in range(t):
	(n,) = map(int, input().split())
	arr = list(map(int, input().split()))
	(m1, m2) = (float('inf'), float('-inf'))
	for i in range(n):
		if arr[i] == -1:
			if i < n - 1 and arr[i + 1] != -1:
				m1 = min(m1, arr[i + 1])
				m2 = max(m2, arr[i + 1])
			if i and arr[i - 1] != -1:
				m1 = min(m1, arr[i - 1])
				m2 = max(m2, arr[i - 1])
	mx = 2
	if m1 > m2:
		mx = 2
	elif m1 == m2:
		mx = m1
	else:
		mx = (m1 + m2) // 2
	mspace = 0
	for i in range(n):
		if arr[i] == -1:
			arr[i] = mx
		if i:
			mspace = max(mspace, abs(arr[i] - arr[i - 1]))
	print(mspace, mx)


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)


t = int(input())
for j in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m_ras = 0
	mi = float('inf')
	ma = -1
	for i in range(n - 1):
		if a[i] == -1:
			if a[i + 1] != -1:
				mi = min(mi, a[i + 1])
				ma = max(ma, a[i + 1])
		elif a[i + 1] == -1:
			mi = min(mi, a[i])
			ma = max(ma, a[i])
		else:
			m_ras = max(abs(a[i] - a[i + 1]), m_ras)
	if ma == -1:
		print(0, 1)
	else:
		ans = (ma + mi) // 2
		print(max(ma - ans, ans - mi, m_ras), ans)


import math, collections, sys
input = sys.stdin.readline

def case():
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	for i in range(1, n):
		if a[i] == -1 and a[i - 1] != -1:
			l.append(a[i - 1])
		if a[i - 1] == -1 and a[i] != -1:
			l.append(a[i])
	if not l:
		k = 1
	else:
		k = (max(l) + min(l)) // 2
	diff = []
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	for i in range(1, n):
		diff.append(abs(a[i] - a[i - 1]))
	print(max(diff), k)
for _ in range(int(input())):
	case()


import math

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(sep=' '):
		return input().split(sep)

	@staticmethod
	def list_int(sep=' '):
		return list(map(int, input().split(sep)))

def solve():
	n = Read.int()
	a = Read.list_int()
	new_a = []
	for i in range(n):
		if a[i] != -1 and (i == 0 or a[i - 1] != -1) and (i == n - 1 or a[i + 1] != -1):
			continue
		new_a.append(a[i])
	new_a = list(filter(lambda x: x != -1, new_a))
	if len(new_a) == 0:
		print('0 0')
		return
	mx = max(new_a)
	mn = min(new_a)
	k = round((mx + mn) / 2)
	m = 0
	for i in range(n - 1):
		p1 = a[i] if a[i] != -1 else k
		p2 = a[i + 1] if a[i + 1] != -1 else k
		r = math.fabs(p1 - p2)
		if r > m:
			m = int(r)
	print(m, k)
query_count = Read.int()
while query_count:
	query_count -= 1
	solve()


import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		(hi, lo) = (10 ** 9, 0)
		ans = 0
		for i in range(1, n):
			ans = max(ans, abs(arr[i] - arr[i - 1]))
		while hi >= lo:
			mid = (hi + lo) // 2
			maxi = -1
			(fl1, fl2) = (0, 0)
			for i in range(1, n):
				(a, b) = (arr[i] if arr[i] != -1 else mid, arr[i - 1] if arr[i - 1] != -1 else mid)
				if abs(a - b) > maxi:
					maxi = abs(a - b)
					(fl1, fl2) = (0, 0)
					if arr[i] == -1:
						if b > mid:
							fl1 = 1
						else:
							fl2 = 1
					elif arr[i - 1] == -1:
						if a > mid:
							fl1 = 1
						else:
							fl2 = 1
				elif abs(a - b) == maxi:
					if arr[i] == -1:
						if b > mid:
							fl1 = 1
						else:
							fl2 = 1
					elif arr[i - 1] == -1:
						if a > mid:
							fl1 = 1
						else:
							fl2 = 1
			ans = min(ans, maxi)
			if not ans:
				break
			elif fl1 and fl2:
				break
			elif fl1:
				lo = mid + 1
			elif fl2:
				hi = mid - 1
			else:
				break
		print(ans, mid)
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()


INF = int(1000000000.0)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	lb = INF
	ub = 0
	wid = 0
	for i in range(n - 1):
		if a[i] == -1 and a[i + 1] == -1:
			continue
		if a[i] == -1:
			lb = min(lb, a[i + 1])
			ub = max(ub, a[i + 1])
		elif a[i + 1] == -1:
			lb = min(lb, a[i])
			ub = max(ub, a[i])
		else:
			wid = max(wid, abs(a[i + 1] - a[i]))
	wid = max(wid, (ub - lb + 1) // 2)
	k = (lb + ub) // 2
	print(wid, k)


def solv():
	x = int(input())
	s = list(map(int, input().split()))
	p = 0
	mx = 0
	mn = 10 ** 9
	for n in range(x):
		if s[n] != -1:
			p = 1
			if n > 0 and s[n - 1] == -1:
				mx = max(mx, s[n])
				mn = min(mn, s[n])
			try:
				if s[n + 1] == -1:
					mx = max(mx, s[n])
					mn = min(mn, s[n])
			except IndexError:
				pass
	if p == 0:
		print(0, 69)
		return
	res = (mx + mn) // 2
	ans = 0
	for n in range(x):
		if s[n] == -1:
			s[n] = res
	for n in range(x):
		if n > 0:
			ans = ans = max(ans, abs(s[n] - s[n - 1]))
		if n < x - 1:
			ans = ans = max(ans, abs(s[n] - s[n + 1]))
	print(ans, res)
for _ in range(int(input())):
	solv()


import math
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	l = []
	diff = []
	for i in range(n - 1):
		if a[i] != -1 and a[i + 1] != -1:
			diff.append(abs(a[i] - a[i + 1]))
		elif a[i] == -1 and a[i + 1] != -1:
			l.append(a[i + 1])
		elif a[i] != -1 and a[i + 1] == -1:
			l.append(a[i])
	nl = list(set(l))
	if len(nl) > 0:
		nk = (max(nl) + min(nl)) // 2
		m11 = abs(nk - max(nl))
	else:
		nk = 1
		m = 0
		print(m, nk)
		continue
	if len(diff) > 0:
		m = max(m11, max(diff))
	else:
		m = m11
	print(m, nk)


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)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	(max1, min1) = (0, 10 ** 9)
	for q in range(len(a)):
		if a[q] != -1:
			if q != n - 1 and a[q + 1] == -1:
				max1 = max(max1, a[q])
				min1 = min(min1, a[q])
			if q != 0 and a[q - 1] == -1:
				max1 = max(max1, a[q])
				min1 = min(min1, a[q])
	(ans, ans1) = ((min1 + max1) // 2, 0)
	for q in range(n - 1):
		if a[q] == -1 and a[q + 1] == -1:
			continue
		elif a[q] == -1:
			ans1 = max(ans1, abs(ans - a[q + 1]))
		elif a[q + 1] == -1:
			ans1 = max(ans1, abs(ans - a[q]))
		else:
			ans1 = max(ans1, abs(a[q] - a[q + 1]))
	print(ans1, 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)


testCases = int(input())
for i1 in range(testCases):
	l = int(input())
	s = list(map(int, input().split()))
	t = []
	diff = []
	for i2 in range(l):
		if s[i2] != -1:
			if i2 == 0:
				if s[i2 + 1] == -1:
					t.append(s[i2])
			elif i2 == l - 1:
				if s[i2 - 1] == -1:
					t.append(s[i2])
			elif s[i2 + 1] == -1 or s[i2 - 1] == -1:
				t.append(s[i2])
			if i2 != l - 1:
				if s[i2 + 1] != -1:
					diff.append(abs(s[i2 + 1] - s[i2]))
	max_diff = 0
	if len(diff) > 0:
		max_diff = max(diff)
	if len(t) == 0:
		print(max_diff, 1)
	else:
		max_t = max(t)
		min_t = min(t)
		t_diff = max_t - min_t
		if t_diff % 2 == 0:
			k = (max_t + min_t) // 2
			t_diff = t_diff // 2
		else:
			k = (max_t + min_t) // 2 + 1
			t_diff = t_diff // 2 + 1
		print(max(max_diff, t_diff), 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()


from math import *
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	k = 0
	re = []
	flag = 0
	d = 0
	d2 = -11111111
	for i in range(n - 1):
		if flag == 0 and (a[i + 1] == -1 and a[i] != -1 or (a[i] == -1 and a[i + 1] != -1)):
			k = max(a[i], a[i + 1])
			d = 0
			flag = 1
			continue
		if a[i] == a[i + 1] == -1:
			continue
		if a[i] == -1 and a[i + 1] != -1:
			new = abs(k - a[i + 1])
			if new > d:
				d1 = ceil((-d + new) / 2)
				d += d1
				if a[i + 1] > k:
					k += d1
				else:
					k -= d1
		elif a[i] != -1 and a[i + 1] == -1:
			new = abs(k - a[i])
			if new > d:
				d1 = ceil((-d + new) / 2)
				d += d1
				if a[i] > k:
					k += d1
				else:
					k -= d1
		else:
			re.append(abs(a[i] - a[i + 1]))
			if re[-1] > d:
				d2 = re[-1]
	re.append(d2)
	for i in range(n):
		if a[i] == -1:
			a[i] = k
	f = 0
	for i in range(n - 1):
		f = max(f, abs(a[i] - a[i + 1]))
	d = max(re + [f])
	print(d, k)


t = int(input())
for a in range(t):
	menor = 1000000000
	maior = 0
	max_diff = 0
	tam = int(input())
	valores = [int(c) for c in input().split()]
	for i in range(tam):
		if valores[i] == -1:
			if i > 0:
				if valores[i - 1] != -1:
					menor = min(valores[i - 1], menor)
					maior = max(valores[i - 1], maior)
			if i < tam - 1:
				if valores[i + 1] != -1:
					menor = min(valores[i + 1], menor)
					maior = max(valores[i + 1], maior)
	media = (maior + menor) // 2
	for i in range(tam):
		if valores[i] == -1:
			valores[i] = media
	for i in range(0, tam - 1):
		max_diff = max(max_diff, abs(valores[i + 1] - valores[i]))
	print(max_diff, media)


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 math
num = int(input())
for _ in range(num):
	_n = int(input())
	a = list(map(int, input().split()))
	diff = 0
	l = set()
	for i in range(len(a) - 1):
		x = a[i]
		y = a[i + 1]
		if x != -1 and y != -1:
			diff = max([diff, abs(x - y)])
		elif x == -1 and y == -1:
			pass
		else:
			l.add(max([x, y]))
	if len(l) != 0:
		ansdif = math.ceil((max(l) - min(l)) / 2)
		ans = min(l) + ansdif
		diff = max([diff, ansdif])
	else:
		ans = 0
	print(diff, ans)


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)


def merge_neg_one(arr):
	merged = []
	for (idx, item) in enumerate(arr):
		if idx == 0:
			merged.append(item)
			continue
		if merged[-1] == -1 and item == -1:
			continue
		merged.append(item)
	return merged

def problem2(arr):
	arr_nonzero = list(filter(lambda x: x != -1, arr))
	if len(arr_nonzero) == 0:
		return '0 0'
	candidates = [min(arr_nonzero), max(arr_nonzero)]
	merged = merge_neg_one(arr)
	for (idx, item) in enumerate(merged):
		if item == -1:
			if idx == 0:
				continue
			if idx == len(merged) - 1:
				continue
			if merged[idx - 1] != -1 and merged[idx + 1] != -1:
				candidates.append(int((merged[idx - 1] + merged[idx + 1]) / 2))
	min_max_adj_diff = 1000000000
	ans = None
	malformed = False
	for candidate in candidates:
		max_adj_diff = 0
		for (idx, item) in enumerate(arr):
			if idx == len(arr) - 1:
				break
			a = arr[idx]
			b = arr[idx + 1]
			if a == -1:
				a = candidate
			if b == -1:
				b = candidate
			adj_diff = abs(a - b)
			if adj_diff > max_adj_diff:
				max_adj_diff = adj_diff
				if a == arr[idx] and b == arr[idx + 1]:
					malformed = True
				else:
					malformed = False
		if max_adj_diff < min_max_adj_diff:
			min_max_adj_diff = max_adj_diff
			ans = candidate
			if malformed:
				ans = min(candidates)
	return f'{min_max_adj_diff} {ans}'

def problem2_1(arr):
	maxn = 0
	minn = 1000000000
	for (idx, item) in enumerate(arr):
		if idx > 0 and item == -1 and (arr[idx - 1] != -1):
			if maxn < arr[idx - 1]:
				maxn = arr[idx - 1]
			if minn > arr[idx - 1]:
				minn = arr[idx - 1]
		if idx < len(arr) - 1 and item == -1 and (arr[idx + 1] != -1):
			if maxn < arr[idx + 1]:
				maxn = arr[idx + 1]
			if minn > arr[idx + 1]:
				minn = arr[idx + 1]
	ans = int((minn + maxn) / 2)
	max_adj_diff = 0
	for (idx, item) in enumerate(arr):
		if idx == 0:
			continue
		a = arr[idx - 1]
		if a == -1:
			a = ans
		b = arr[idx]
		if b == -1:
			b = ans
		adj_diff = abs(a - b)
		if adj_diff > max_adj_diff:
			max_adj_diff = adj_diff
	return f'{max_adj_diff} {ans}'
N = int(input())
for i in range(N):
	num = input()
	arr = list(map(lambda x: int(x), input().split(' ')))
	print(problem2_1(arr))


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)


m = int(input())
import math
for _ in range(m):
	n = int(input())
	lst1 = list(map(int, input().split()))
	(max_, min_) = (0, 10 ** 9 + 10)
	ct = 0
	for i in range(n):
		if i > 0 and lst1[i] == -1 and (lst1[i - 1] != -1):
			max_ = max(max_, lst1[i - 1])
			min_ = min(min_, lst1[i - 1])
		if i < n - 1 and lst1[i] == -1 and (lst1[i + 1] != -1):
			max_ = max(max_, lst1[i + 1])
			min_ = min(min_, lst1[i + 1])
	mid = math.ceil((max_ + min_) / 2)
	abs_ = 0
	for i in range(n):
		if not i:
			bef = lst1[i] if lst1[i] != -1 else mid
			continue
		if lst1[i] == -1:
			abs_ = max(abs_, abs(mid - bef))
			bef = mid
		else:
			abs_ = max(abs_, abs(lst1[i] - bef))
			bef = lst1[i]
	print(abs_, mid)


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)


import sys
import copy
from math import *
input = sys.stdin.readline

def bo(i):
	return ord(i) - ord('a')
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	a = [int(x) for x in input().split()]
	if a.count(-1) == n:
		print(0, 5)
		continue
	s = []
	for i in range(n):
		if a[i] != -1:
			if i != 0:
				if a[i - 1] == -1:
					s.append(a[i])
			if i != n - 1:
				if a[i + 1] == -1:
					s.append(a[i])
	k = 2
	ss = max(s) + min(s)
	s = ss
	if k > 0:
		g = s // k
	b = copy.deepcopy(a)
	for i in range(n):
		if a[i] == -1:
			a[i] = g
	maxi = -10 ** 18
	for i in range(1, n):
		maxi = max(maxi, abs(a[i] - a[i - 1]))
	m1 = maxi
	if s % k == 0:
		print(maxi, g)
		continue
	g2 = s // k + 1
	for i in range(n):
		if b[i] == -1:
			b[i] = g2
	maxi = -10 ** 18
	for i in range(1, n):
		maxi = max(maxi, abs(b[i] - b[i - 1]))
	m2 = maxi
	if m1 < m2:
		print(m1, g)
	else:
		print(m2, g2)