#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>//memset(a, 0, sizeof(a));

#define maxlongint 2147483647
#define ll long long
#define fo(i, x, y) for (int i = x; i <= y; i++)
#define fd(i, x, y) for (int i = x; i >= y; i--)
#define N 1000005
using namespace std;
int n,a[N],ans;
void init() {
	freopen("e.in","r",stdin);
	//freopen("e.out","w",stdout);
}
void qsort(int l,int r) {
	int i=l,j=r,mid=a[(i+j)/2];
	while (i<=j) {
		while (a[i]<mid) i++;
		while (a[j]>mid) j--;
		if (i<=j) {
			if (i!=j) ans++;
			swap(a[i],a[j]);
			i++;
			j--;
		}
	}
	if (i<r) qsort(i,r);
	if (l<j) qsort(l,j);
}
int main() {
	//init();
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	qsort(1,n);
	if (ans<=3*n) printf("Petr");
	else printf("Um_nik");
	return 0;
}


#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<cstring>//memset(a, 0, sizeof(a));

#define maxlongint 2147483647
#define ll long long
#define fo(i, x, y) for (int i = x; i <= y; i++)
#define fd(i, x, y) for (int i = x; i >= y; i--)
#define N 1000005
using namespace std;
int n,a[N],ans;
void init() {
	freopen("e.in","r",stdin);
	//freopen("e.out","w",stdout);
}
void qsort(int l,int r) {
	int i=l,j=r,mid=a[(i+j)/2];
	while (i<=j) {
		while (a[i]<mid) i++;
		while (a[j]>mid) j--;
		if (i<=j) {
			if (i!=j) ans++;
			swap(a[i],a[j]);
			i++;
			j--;
		}
	}
	if (i<r) qsort(i,r);
	if (l<j) qsort(l,j);
}
int main() {
	//init();
	scanf("%d",&n);
	fo(i,1,n) scanf("%d",&a[i]);
	qsort(1,n);
	if (ans%2==3*n%2) printf("Petr");
	else printf("Um_nik");
	return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
int n,a[1000010],pos[1000010],ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),pos[a[i]]=i;
	for (int i=1;i<=n;i++)
	{
		if (pos[i]!=i)
		{
			ans++;
			pos[a[i]]=pos[i];
			swap(a[i],a[pos[i]]);
		}
	}
	if (n&1)
	{
		if (ans&1) printf("Petr");
		else printf("Um_nik");
	}
	else
	{
		if (ans&1) printf("Um_nik");
		else printf("Petr");
	}
}


#include<cstdio>
#include<iostream>
using namespace std;
int n,a[1000010],pos[1000010],ans;
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),pos[a[i]]=i;
	for (int i=1;i<=n;i++)
	{
		if (pos[i]!=i)
		{
			ans++;
			pos[a[i]]=pos[i];
		}
	}
	if (n&1)
	{
		if (ans&1) printf("Petr");
		else printf("Um_nik");
	}
	else
	{
		if (ans&1) printf("Um_nik");
		else printf("Petr");
	}
}


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int MAXN = 1000000 + 1;

int n;
int cnt;
int d[MAXN];

int main(int argc, char const *argv[])
{
	//freopen("init.in", "r", stdin);
	scanf("%d", &n);

	for (int i = 1; i <= n; i++)
		scanf("%d", &d[i]);

	for (int i = 1; i <= n; i++)
		for (; d[i] != i; cnt++)
			swap(d[i], d[d[i]]);

	if (!((n * 3 - cnt) % 2))
		printf("Petr\n");
	else
		printf("Um_nik\n");

	return 0;
}


#include <cstdio>

using namespace std;

int i,n,a[1000010],b[1000010],sum,t;

inline void re(int &x)
{
	x=0;
	bool flag=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') flag|=(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	x=flag ? -x : x;
}

int main()
{
	re(n);
	for(i=1;i<=n;i++)
	{
		re(a[i]);
		b[a[i]]=i;
	}
	for(i=1;i<=n;i++)
		if(a[i]!=i)
		{
			sum++;
			t=b[i];
			a[t]=a[i];
			b[a[i]]=t;
		}
	if(sum%2==3*n%2) printf("Petr\n");
	else printf("Um_nik\n");
	return 0;
}


#include<stdio.h>

int ipt[1000006];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <=n; ++i) {
		scanf("%d", ipt+i);
	}
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		while (ipt[i] != i)
		{
			cnt++;
			int op = ipt[i];
			ipt[i] = ipt[op];//把这个数换到正确的位置
			ipt[op] = op;
		}
	}
	if((cnt+3*n)&1)printf("Um_nik");
	printf("Petr");
}


#include<stdio.h>

int ipt[1000006];

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 1; i <=n; ++i) {
		scanf("%d", ipt+i);
	}
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		while (ipt[i] != i)
		{
			cnt++;
			int op = ipt[i];
			ipt[i] = ipt[op];//把这个数换到正确的位置
			ipt[op] = op;
		}
	}
	if((cnt+3*n)&1)printf("Um_nik");
	else printf("Petr");
}


#include<stdio.h>

int main() {
	int n;
	scanf("%d", &n);
	int cnt = 0,a0;
	for (int i = 1; i <=n; ++i) {
		scanf("%d", &a0);
		cnt += (a0 != i);
	}
	if ((cnt + 3 * n) & 1)printf("Um_nik");
	else printf("Petr");
}


#include "bits/stdc++.h"
using namespace std;

int main()
{
	int N;
	cin>>N;
	int A[N+1];
	int idx[N+1];
	for(int i=1; i<=N; i++)
	{
		cin>>A[i];
		idx[A[i]] = i;
	}
	int cnt = 0;
	for(int i=1; i<=N; i++)
	{
		if(A[i] == i)continue;
		//Get i here
		int tmp_idx = idx[i];
		int tmp_val = A[i];
		swap(A[i], A[idx[i]]);
		idx[i] = i;
		idx[tmp_val] = tmp_idx;
		cnt++;
	}
	if((cnt%2) == (3*N)%2)
		cout<<"Petr\n";
	else
		cout<<"Um_nik\n";
	return 0;
}


#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;
int N;
int cont;
long long res[100000];
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> N;
    for(int i =0; i<  N; i++) cin >>res[i];

    for (int i =0; i < N; i++) {
        if (res[i]==i+1)continue;
        cont++;
        swap(res[i],res[res[i]-1]);
    }
    if ((3*N+cont)%2==0) {
        cout << "Petr";
    }else cout <<"Um_nik";
    return 0;
}


#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;
int N;
int cont;
int res[1000000];
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> N;
    for(int i =0; i<  N; i++) cin >>res[i];

    for (int i =0; i < N; i++) {
        if (res[i]==i+1)continue;
        cont++;
        swap(res[i],res[res[i]-1]);
    }
    if ((3*N+cont)%2==0) {
        cout << "Petr";
    }else cout <<"Um_nik";
    return 0;
}


#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;
int N;
int cont;
int res[1000000];
int ind[1000000];
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin >> N;
    for(int i =0; i<  N; i++){

     cin >>res[i];
     ind[--res[i]]=i;
    }
    for (int i =0; i < N; i++) {
        if (ind[i]==i)continue;
        cont++;
        int tmp = ind[i];
        swap(res[ind[i]],res[i]);
        ind[i]=i;
        ind[res[tmp]]=tmp;;
    }
    if ((3*N+cont)%2==0) {
        cout << "Petr";
    }else cout <<"Um_nik";
    return 0;
}


#include<bits/stdc++.h>

using namespace std;

void func(int* arr,int i);

int main()
{
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<n+1;i++)
		cin>>arr[i];
	int count=0;
	for(int i=1;i<n+1;i++)
	{
		if(arr[i]!=-1)
		{
			func(arr,i);
			count++;
		}
	}

	int ret=n-count;
	if(n%2==0)
	{
		if(ret%2==0)
			cout<<"Petr"<<endl;
		else
			cout<<"Um_nik"<<endl;
	}
	else
	{
		if(ret%2!=0)
			cout<<"Petr"<<endl;
		else
			cout<<"Um_nik"<<endl;
	}

	return 0;
}

void func(int* arr,int i)
{
	int st=i;
	while(arr[i]!=st)
	{
		int temp=arr[i];
		arr[i]=-1;
		i=temp;
	}
	arr[i]=-1;
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int cnt,n,a[N],in[N];

int main(){
	int i,j,t;
	scanf("%d",&n);
	for(i=1;i<=n;++i){scanf("%d",&a[i]);in[a[i]]=i;}
    for(i=1;i<=n;++i){
    	if(a[i]!=i){
    	   j=in[i];
		   a[j]=a[i];in[a[i]]=j;a[i]=i;
		   cnt++;
		}
	}
	if(cnt%3==0) printf("Petr\n");
	else printf("Um_nik\n");
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int cnt,n,a[N],in[N];

int main(){
	int i,j,t;
	scanf("%d",&n);
	for(i=1;i<=n;++i){scanf("%d",&a[i]);in[a[i]]=i;}
    for(i=1;i<=n;++i){
    	if(a[i]!=i){
    	   j=in[i];
		   a[j]=a[i];in[a[i]]=j;a[i]=i;
		   cnt++;
		}
	}
	if((3*n%(2*cnt))%cnt==0) printf("Petr\n");
	else printf("Um_nik\n");
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int cnt,n,a[N],in[N];

int main(){
	int i,j,t;
	scanf("%d",&n);
	for(i=1;i<=n;++i){scanf("%d",&a[i]);in[a[i]]=i;}
    for(i=1;i<=n;++i){
    	if(a[i]!=i){
    	   j=in[i];
		   a[j]=a[i];in[a[i]]=j;a[i]=i;
		   cnt++;
		}
	}
	if(3%cnt==0 || cnt%3==0 || n%cnt==0) printf("Petr\n");
	else printf("Um_nik\n");
}


#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int cnt,n,a[N],in[N];

int main(){
	int i,j,t;
	scanf("%d",&n);
	for(i=1;i<=n;++i){scanf("%d",&a[i]);in[a[i]]=i;}
    for(i=1;i<=n;++i){
    	if(a[i]!=i){
    	   j=in[i];
		   a[j]=a[i];in[a[i]]=j;a[i]=i;
		   cnt++;
		}
	}
	if((3*n-cnt)%2==0) printf("Petr\n");
	else printf("Um_nik\n");
}


#include <bits/stdc++.h>

using namespace std;

long long ans, k, cnt;
int n, a[1010101], check[1010101], imsi;

int main()
{
    int i, j;
    scanf("%d", &n);
    for(i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for(i = 1; i <= n; i++) {
        if(check[i]) continue;
        imsi = i;
        cnt = 1;
        while(1) {
        if(check[imsi]) break;
        check[i] = 1;
        imsi = a[imsi];
        cnt++;
        }
        cnt = (cnt - 1) * (cnt - 2) / 2;
        ans += cnt;
    }
    if(ans & 1) printf("Petr");
    else printf("Um_nik");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long ans, k, cnt;
int n, a[1010101], check[1010101], imsi;

int main()
{
    int i, j;
    scanf("%d", &n);
    for(i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for(i = 1; i <= n; i++) {
        if(check[i]) continue;
        imsi = a[i];
        cnt = 0;
        while(1) {
        if(check[imsi]) break;
        check[imsi] = 1;
        imsi = a[imsi];
        cnt++;
        }
        cnt = (cnt - 1);
        ans += cnt;
    }
    if((ans & 1) == ((3 * n) & 1) ) printf("Petr");
    else printf("Um_nik");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long ans, k, cnt;
int n, a[1010101], check[1010101], imsi;

int main()
{
    int i, j;
    scanf("%d", &n);
    for(i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for(i = 1; i <= n; i++) {
        if(check[i]) continue;
        imsi = a[i];
        cnt = 0;
        while(1) {
        if(check[imsi]) break;
        check[imsi] = 1;
        imsi = a[imsi];
        cnt++;
        }
        cnt = (cnt - 1);
        ans += cnt;
    }
    if(ans & 1) printf("Petr");
    else printf("Um_nik");
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

long long ans, k, cnt;
int n, a[1010101], check[1010101], imsi;

int main()
{
    int i, j;
    scanf("%d", &n);
    for(i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for(i = 1; i <= n; i++) {
        if(check[i]) continue;
        imsi = a[i];
        cnt = 1;
        while(1) {
        if(check[imsi]) break;
        check[i] = 1;
        imsi = a[imsi];
        }
        cnt = cnt * (cnt + 1) / 2;
        ans += cnt;
    }
    if(ans & 1) printf("Petr");
    else printf("Um_nik");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int p=1e9+7;
ll a[1234567];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	map<int,int> indx;
	for(int i=1;i<=n;i++)
	indx[a[i]]=i;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i)
		continue;
		int loc=indx[i];
		indx[a[i]]=loc;
		swap(a[loc],a[i]);
		indx[i]=i;
		cnt++;
	}
	while(cnt!=3*n && cnt!=7*n+1)
	cnt+=2;
	if(cnt==3*n)
	cout<<"Petr"<<endl;
	else
	cout<<"Um_nik"<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int p=1e9+7;
ll a[1234567],indx[1234567];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	for(int i=1;i<=n;i++)
	indx[a[i]]=i;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i)
		continue;
		int loc=indx[i];
		indx[a[i]]=loc;
		swap(a[loc],a[i]);
		indx[i]=i;
		cnt++;
	}
	while(cnt!=3*n && cnt!=7*n+1)
	cnt+=2;
	if(cnt==3*n)
	cout<<"Petr"<<endl;
	else
	cout<<"Um_nik"<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int p=1e9+7;
ll a[1234567];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	map<int,int> indx;
	for(int i=1;i<=n;i++)
	indx[a[i]]=i;
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(a[i]==i)
		continue;
		int loc=indx[i];
		swap(a[loc],a[i]);
		indx[a[i]]=i;
		indx[a[loc]]=loc;
		cnt++;
	}
	while(cnt!=3*n && cnt!=7*n+1)
	cnt+=2;
	if(cnt==3*n)
	cout<<"Petr"<<endl;
	else
	cout<<"Um_nik"<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n;
int a[1001000];
int pos[1001000];
int tree[5001000];

int update(int l, int i = 1, int cl=1, int cr=n) {
    if (cl == cr && cr == l)
        tree[i] = 1;
    else {
        int mid = (cl + cr) / 2;
        if (l <= mid)
            update(l, 2*i,  cl, mid);
        else
            update(l, 2*i+1, mid+1, cr);
        tree[i] = tree[2*i] + tree[2*i+1];
    }
}

int sum(int l, int r, int i = 1, int cl=1, int cr=n) {
    if (cl > r || cr < l || cl > cr)
        return 0;
    else if (l <= cl && cr <= r)
        return tree[i];
    else {
        int mid = (cl + cr) / 2;
        return sum(l, r, 2*i, cl, mid) + sum(l, r, 2*i+1, mid+1, cr);
    }
}

int main(void) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    int inv = 0;
    for (int i = n; i >= 1; i--) {
        inv = (inv + sum(a[i] + 1, n)) % 2;
        update(a[i]);
    }
    if (inv == (3 * n) % 2)
        printf("Petr\n");
    else
        printf("Um_nik\n");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n;
int a[1001000];
int pos[1001000];
int tree[5001000];

int update(int l, int i = 1, int cl=1, int cr=n) {
    if (cl == cr && cr == l)
        tree[i] = 1;
    else {
        int mid = (cl + cr) / 2;
        if (l <= mid)
            update(l, 2*i,  cl, mid);
        else
            update(l, 2*i+1, mid+1, cr);
        tree[i] = tree[2*i] + tree[2*i+1];
    }
}

int sum(int l, int r, int i = 1, int cl=1, int cr=n) {
    if (cl > r || cr < l || cl > cr)
        return 0;
    else if (l <= cl && cr <= r)
        return tree[i];
    else {
        int mid = (cl + cr) / 2;
        return sum(l, r, 2*i, cl, mid) + sum(l, r, 2*i+1, mid+1, cr);
    }
}

int main(void) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    int inv = 0;
    for (int i = n; i >= 1; i--) {
        inv = (inv + sum(1, a[i])) % 2;
        update(a[i]);
    }
    if (inv == ((3 * n) % 2))
        printf("Petr\n");
    else
        printf("Um_nik\n");
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int n;
int a[1001000];
int pos[1001000];
int tree[5001000];

int update(int l, int i = 1, int cl=1, int cr=n) {
    if (cl == cr && cr == l)
        tree[i] = 1;
    else {
        int mid = (cl + cr) / 2;
        if (l <= mid)
            update(l, 2*i,  cl, mid);
        else
            update(l, 2*i+1, mid+1, cr);
        tree[i] = tree[2*i] + tree[2*i+1];
    }
}

int sum(int l, int r, int i = 1, int cl=1, int cr=n) {
    if (cl > r || cr < l || cl > cr)
        return 0;
    else if (l <= cl && cr <= r)
        return tree[i];
    else {
        int mid = (cl + cr) / 2;
        return sum(l, r, 2*i, cl, mid) + sum(l, r, 2*i+1, mid+1, cr);
    }
}

int main(void) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        scanf("%d", &a[i]);
    int inv = 0;
    for (int i = n; i >= 1; i--) {
        inv = (inv + sum(a[i] + 1, n)) % 2;
        update(a[i]);
    }
    if (inv == ((3 * n) % 2))
        printf("Petr\n");
    else
        printf("Um_nik\n");
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
typedef long long LL;

int n;
LL tree[maxn];

void add(int x) {
    while(x<maxn) {
        tree[x]++;
        x+=x&-x;
    }
}

LL sum(int x) {
    LL res = 0;
    while(x) {
        res+=tree[x];
        x-=x&-x;
    }
    return res;
}

int main() {
    scanf("%lld",&n);
    LL ans = 0;
    for(int i=0;i<n;i++) {
        LL x;scanf("%lld",&x);
        ans+= sum(n)- sum(x);
        add(x);
    }
    //printf("%lld\n",ans);
    if((ans&1) == ((3*n)&1)) puts("Petr");
    else puts("Um_nik");
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
typedef long long LL;

int n;
LL tree[maxn];

void add(int x) {
    while(x<maxn) {
        tree[x]++;
        x+=x&-x;
    }
}

LL sum(int x) {
    LL res = 0;
    while(x) {
        res+=tree[x];
        x-=x&-x;
    }
    return res;
}

int main() {
    scanf("%lld",&n);
    LL ans = 0;
    for(int i=0;i<n;i++) {
        LL x;scanf("%lld",&x);
        add(x);
        ans+=sum(x-1);
    }
    //printf("%lld\n",ans);
    if(ans&1) puts("Petr");
    else puts("Um_nik");
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
typedef long long LL;

int n;
LL tree[maxn];

void add(int x) {
    while(x<maxn) {
        tree[x]++;
        x+=x&-x;
    }
}

LL sum(int x) {
    LL res = 0;
    while(x) {
        res+=tree[x];
        x-=x&-x;
    }
    return res;
}

int main() {
    scanf("%lld",&n);
    LL ans = 0;
    for(int i=0;i<n;i++) {
        LL x;scanf("%lld",&x);
        ans+= sum(n)- sum(x);
        add(x);
    }
    //printf("%lld\n",ans);
    if(ans&1 == ((3*n)&1)) puts("Petr");
    else puts("Um_nik");
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
typedef long long LL;

int n;
LL tree[maxn];

void add(int x) {
    while(x<maxn) {
        tree[x]++;
        x+=x&-x;
    }
}

LL sum(int x) {
    LL res = 0;
    while(x) {
        res+=tree[x];
        x-=x&-x;
    }
    return res;
}

int main() {
    scanf("%lld",&n);
    LL ans = 0;
    for(int i=0;i<n;i++) {
        LL x;scanf("%lld",&x);
        add(x);
        ans+=(i+1) - sum(x);
    }
    //printf("%lld\n",ans);
    if(ans&1) puts("Petr");
    else puts("Um_nik");
}


#include<bits/stdc++.h>
using namespace std;
vector<long long > graph[1100000];
int vis[1100000];
long long a[1100000];
void dfs(long long i)
{
	vis[i]=1;
	for(vector<long long> :: iterator it=graph[i].begin();it!=graph[i].end();++it)
	{
		if(vis[*it]==0)
		{
			dfs(*it);
		}
	}
	return;
}
int main()
{
	long long n,i,count=0;
	cin >> n;
	for(i=1;i<=n;i++)
	{
		cin >> a[i];
		vis[i]=0;
		graph[i].push_back(a[i]);
	}
	for(i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
			dfs(i);
			count++;
		}
	}
	if( ((n-count)%2==0 && n%2==1) || ((n-count)%2==1 && n%2==0) )
	{
		cout <<"Um_nik\n" ;
	}
	else
		cout << "Petr\n";
	return 0;
}


#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
vector<long long > graph[1100000];
int vis[1100000];
long long a[1100000];
void dfs(long long i)
{
	vis[i]=1;
	for(vector<long long> :: iterator it=graph[i].begin();it!=graph[i].end();++it)
	{
		if(vis[*it]==0)
		{
			dfs(*it);
		}
	}
	return;
}
int main()
{
	long long n,i,count=0;
	cin >> n;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		vis[i]=0;
		graph[i].push_back(a[i]);
	}
	for(i=1;i<=n;i++)
	{
		if(vis[i]==0)
		{
			dfs(i);
			count++;
		}
	}
	if( ((n-count)%2==0 && n%2==1) || ((n-count)%2==1 && n%2==0) )
	{
		cout <<"Um_nik\n" ;
	}
	else
		cout << "Petr\n";
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000005];
int b[1000005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        a[i]=x;
        b[x]=i;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=i)
        {
            a[b[i]]=a[i];
            b[a[i]]=b[i];
            ans++;
        }
    }
    if(3*n%2==ans%2)printf("Peter");
    else printf("Um_nik");

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[1000005];
int b[1000005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        a[i]=x;
        b[x]=i;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]!=i)
        {
            a[b[i]]=a[i];
            b[a[i]]=b[i];
            ans++;
        }
    }
    if(3*n%2==ans%2)printf("Petr");
    else printf("Um_nik");

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[100005],b[100005];
long long ans;
void mergesort(int l,int mid,int r)
{
    int i=l,j=mid+1,k=0;
    while(i<=mid&&j<=r)
    {
        if(a[i]<=a[j])
            b[k++]=a[i++];
        else
        {
            b[k++]=a[j++];
            ans+=mid-i+1;
        }
    }
    while(i<=mid)
        b[k++]=a[i++];
    while(j<=r)
        b[k++]=a[j++];
    for(int w=0;w<k;w++)
        a[l+w]=b[w];
}
void work(int l,int r)
{
    if(l<r)
    {
        int mid=(l+r)>>1;
        work(l,mid);
        work(mid+1,r);
        mergesort(l,mid,r);
    }
}
int main()
{
    ios::sync_with_stdio(false);
	cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    work(1,n);
    if(n&1)
    {
    if(ans%2==0)
    	cout<<"Um_nik"<<endl;
    else
    	cout<<"Petr"<<endl;
    }
	else
	{
	if(ans%2==0)
    	cout<<"Petr"<<endl;
    else
    	cout<<"Um_nik"<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,ans;
int a[1000005];
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		ans+=abs(a[i]-i);
	if(ans&1)
		puts("Um_nik");
	else
		puts("Petr");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int n,a[1000005],b[1000005];
long long ans;
void mergesort(int l,int mid,int r)
{
    int i=l,j=mid+1,k=0;
    while(i<=mid&&j<=r)
    {
        if(a[i]<=a[j])
            b[k++]=a[i++];
        else
        {
            b[k++]=a[j++];
            ans+=mid-i+1;
        }
    }
    while(i<=mid)
        b[k++]=a[i++];
    while(j<=r)
        b[k++]=a[j++];
    for(int w=0;w<k;w++)
        a[l+w]=b[w];
}
void work(int l,int r)
{
    if(l<r)
    {
        int mid=(l+r)>>1;
        work(l,mid);
        work(mid+1,r);
        mergesort(l,mid,r);
    }
}
int main()
{
    ios::sync_with_stdio(false);
	cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    work(1,n);
    if(n&1)
    {
    if(ans%2==0)
    	cout<<"Um_nik"<<endl;
    else
    	cout<<"Petr"<<endl;
    }
	else
	{
	if(ans%2==0)
    	cout<<"Petr"<<endl;
    else
    	cout<<"Um_nik"<<endl;
	}
    return 0;
}


#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdio>
using namespace std;

typedef long long ll;
const int MAX=1000005;

int a[MAX];
int t[MAX<<3];
int k=1;

inline void Add(int x)
{
//	printf("Add %d\n",x);
	x=k+x-1;
	t[x]=1;
	x>>=1;

	while(x)
	{
		t[x]=t[x<<1]+t[(x<<1)+1];
		x>>=1;
	}
}

inline int Query(int x,const int l,const int r,int a,int b)
{
//	printf("Query %d %d %d %d %d\n",x,l,r,a,b);
	if(r<a || l>b)
		return 0;
	if(l<=a && r>=b)
		return t[x];

	return Query(x<<1,l,r,a,a+((b-a-1)>>1))+Query((x<<1)+1,l,r,a+1+((b-a-1)>>1),b);
}

int main()
{
//	freopen("input.txt","r",stdin);

	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);

	while(k<n)
		k<<=1;
//	printf("%d\n",k);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=Query(1,a[i]+1,n,1,k);
		Add(a[i]);
	}

	if((ans&1)==(n&1))
		printf("Petr\n");
	else
		printf("Um_nik\n");
	return 0;
}


#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <cstdio>
using namespace std;

typedef long long ll;
const int MAX=1000005;

int a[MAX];
int t[MAX<<3];
int k=1;

inline void Add(int x)
{
//	printf("Add %d\n",x);
	x=k+x-1;
	t[x]=1;
	x>>=1;

	while(x)
	{
		t[x]=t[x<<1]+t[(x<<1)+1];
		x>>=1;
	}
}

inline int Query(int x,const int l,const int r,int a,int b)
{
//	printf("Query %d %d %d %d %d\n",x,l,r,a,b);
	if(r<a || l>b)
		return 0;
	if(l<=a && r>=b)
		return t[x];

	return Query(x<<1,l,r,a,a+((b-a-1)>>1))+Query((x<<1)+1,l,r,a+1+((b-a-1)>>1),b);
}

int main()
{
//	freopen("input.txt","r",stdin);

	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);

	while(k<n)
		k<<=1;
//	printf("%d\n",k);
	ll ans=0;
	for(int i=1;i<=n;i++)
	{
		ans+=Query(1,a[i]+1,n,1,k);
		Add(a[i]);
	}

	printf((ans&1)?"Petr\n":"Um_nik\n");
	return 0;
}


#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <time.h>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <string>
#include <string.h>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

#define For(i, s, n) for (int i = s; i <= n; ++i)
#define ForD(i, s, n) for (int i = s; i >= n; --i)
#define ForV(i, n) for (int i = 0; i < n; ++i)
#define pb push_back
#define ms(a, x) memset(a, x, sizeof(a))
#define sz(a) ((int)(a).size())
#define ii pair<int, int>
#define fi first
#define se second

typedef long long ll;

const int N = 1e6 + 5, LIMIT = 1e9 + 7;

int a[N], id[N];
int n, odd, res = 0;

void Read()
{
    //freopen("CF987E.INP", "r", stdin);
    //freopen("CF987E.OUT", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin >> n;
    For (i, 1, n)
    {
        cin >> a[i];
        id[a[i]] = i;
    }
    odd = (3 * n) % 2;
}

void Process()
{
    For (i, 1, n)
    {
        if (id[i] != i)
        {
            int u = i, v = a[i];
            ++res;
            swap(a[id[i]], a[i]);
            swap(id[u], id[v]);
        }
    }
}

void Print()
{
    if (odd == (res % 2))
    {
        cout << "Petr";
    }
    else cout << "Um_nik";
}

int main()
{
    Read();
    Process();
    Print();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin>>n;

	vector<int> mp(n+1);
	vector<int> arr(n+1);
	arr[0]=0;
	mp[0]=0;

	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
		mp[arr[i]]=i;
	}

	int scount=0;
	for(int i=1;i<=n;i++)
	{
		if(arr[i]!=i)
		{
			int temp=arr[i],index=mp[i];
			swap(arr[i],arr[index]);
			scount++;
			mp[i]=i;
			mp[temp]=index;
		}
	}

	if(n%2==0 && scount%2==0)
	{
		cout<<"Petr"<<endl;
	}
	else if(n%2==0 && scount%2==1)
	{
		cout<<"Um_nik"<<endl;
	}
	else if(n%2==1 && scount%2==0)
	{
		cout<<"Um_nik"<<endl;
	}
	else
	{
		cout<<"Petr"<<endl;
	}
}


#include<bits/stdc++.h>
using namespace std;

int main()
{
	int n;
	cin>>n;

	map<int,int> mp;
	vector<int> arr(n+1);
	arr[0]=0;

	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
		mp[arr[i]]=i;
	}
	int scount=0;
	for(int i=1;i<=n;i++)
	{
		if(arr[i]!=i)
		{
			int temp=arr[i],index=mp[i];
			swap(arr[i],arr[index]);
			scount++;
			mp[i]=i;
			mp[temp]=index;
		}
	}

	if(n%2==0 && scount%2==0)
	{
		cout<<"Petr"<<endl;
	}
	else if(n%2==0 && scount%2==1)
	{
		cout<<"Um_nik"<<endl;
	}
	else if(n%2==1 && scount%2==0)
	{
		cout<<"Um_nik"<<endl;
	}
	else
	{
		cout<<"Petr"<<endl;
	}
}


#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;

int datas[1000005];
int tmp[1000005];
ll cnt;
void combine(int L, int R)
{
	int mid=(L+R)/2;
	int p1=L, p2=mid+1, pos=L;
	while(p1 <= mid || p2 <= R)
	{
		if(p1 > mid)
		{
			tmp[pos]=datas[p2];
			p2++;
		}
		else if(p2 > R)
		{
			tmp[pos]=datas[p1];
			p1++;
		}
		else if(datas[p1] > datas[p2])
		{
			cnt=cnt+(mid-(p1-1));
			tmp[pos]=datas[p2];
			p2++;
		}
		else
		{
			tmp[pos]=datas[p1];
			p1++;
		}
		pos++;
	}
	for(int a=L;a<=R;a++)
	{
		datas[a]=tmp[a];
	}
}

void sorting(int L, int R)
{
	if(L>=R) return;
	int mid=(L+R)/2;
	sorting(L, mid); sorting(mid+1, R);
	combine(L, R);
}

int main()
{
	int n;
	scanf("%d", &n);
	for(int a=0;a<n;a++)
	{
		scanf("%d", &datas[a]);
	}
	cnt=0;
	sorting(0, n-1);
	for(int a=0;a<n;a++)
	{
		cout<<datas[a]<<" ";
	}
	if(cnt%2==1)
	{
		if(n%2==1)
		{
			cout<<"Petr";
		}
		else
		{
			cout<<"Um_nik";
		}
	}
	else if(cnt%2==0)
	{
		if(n%2==0)
		{
			cout<<"Petr";
		}
		else
		{
			cout<<"Um_nik";
		}
	}
	cout<<endl;
	return 0;
}


#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;

int datas[1000005];
int tmp[1000005];
ll cnt;
void combine(int L, int R)
{
	int mid=(L+R)/2;
	int p1=L, p2=mid+1, pos=L;
	while(p1 <= mid || p2 <= R)
	{
		if(p1 > mid)
		{
			tmp[pos]=datas[p2];
			p2++;
		}
		else if(p2 > R)
		{
			tmp[pos]=datas[p1];
			p1++;
		}
		else if(datas[p1] > datas[p2])
		{
			cnt=cnt+(mid-(p1-1));
			tmp[pos]=datas[p2];
			p2++;
		}
		else
		{
			tmp[pos]=datas[p1];
			p1++;
		}
		pos++;
	}
	for(int a=L;a<=R;a++)
	{
		datas[a]=tmp[a];
	}
}

void sorting(int L, int R)
{
	if(L>=R) return;
	int mid=(L+R)/2;
	sorting(L, mid); sorting(mid+1, R);
	combine(L, R);
}

int main()
{
	int n;
	scanf("%d", &n);
	for(int a=0;a<n;a++)
	{
		scanf("%d", &datas[a]);
	}
	cnt=0;
	sorting(0, n-1);
//	for(int a=0;a<n;a++)
//	{
//		cout<<datas[a]<<" ";
//	}
	if(cnt%2==1)
	{
		if(n%2==1)
		{
			cout<<"Petr";
		}
		else
		{
			cout<<"Um_nik";
		}
	}
	else if(cnt%2==0)
	{
		if(n%2==0)
		{
			cout<<"Petr";
		}
		else
		{
			cout<<"Um_nik";
		}
	}
	cout<<endl;
	return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string.h>
using namespace std;
int a[400005];

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        int sum=0, num=0, maxn=0,pos=0,maxnum=0,m=0,k=0,minnum=1000000005;
        a[0] = -1,a[n]=-1;
        for (int i = 1; i <= n;i++)
        {
            cin >> a[i];
            if(a[i]!=-1&&a[i-1]!=-1)
            {
                if(abs(a[i]-a[i-1])>maxn)
                {
                	maxn=abs(a[i]-a[i-1]);
                	pos=i;
				}
            }
        }
        for (int i = 1; i <= n;i++)
        {
            if(a[i]!=-1&&(a[i-1]==-1||a[i+1]==-1))
            {
                 sum += a[i];
                num++;
                maxnum = max(maxnum, a[i]);
                minnum=min(minnum,a[i]);
            }
        }
		if(num==0) num=1;
        sum /= num;
        int sum1=sum+1;
        int x1=max(maxnum-sum,sum-minnum);
        int x2=max(maxnum-sum1,sum1-minnum);
        if(x1>=maxn||x2>=maxn)
        {
            if(x1<x2)
            {
            	m=x1;
            	k=sum;
			}
			else
			{
				m=x2;
				k=sum1;
			}
        }
        else
        {
             m = maxn;
             k = a[pos];
        }
        printf("%d %d\n", m, k);
    }
        return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string.h>
using namespace std;
int a[400005];

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int sum = 0, num = 0, maxn = 0, pos = 0, maxnum = 0, m = 0, k = 0, minnum = 1000000005;
        for (int i = 1; i <= n; i++)
        {
            cin >> a[i];
        }
        if (a[1] != -1 && a[2] == -1)
        {
            maxnum = max(maxnum, a[1]);
            minnum = min(minnum, a[1]);
        }
        if (a[n] != -1 && a[n - 1] == -1)
        {

            num++;
            maxnum = max(maxnum, a[n]);
            minnum = min(minnum, a[n]);
        }
        for (int i = 2; i <= n - 1; i++)
        {

            if (a[i] != -1 && (a[i - 1] == -1 || a[i + 1] == -1))
            {

                maxnum = max(maxnum, a[i]);
                minnum = min(minnum, a[i]);
            }
        }
        sum = (maxnum + minnum) / 2;
        int ans = 0;
        for (int i = 1; i <= n;i++)
        {
            if(a[i]==-1)
            {
                a[i] = sum;
            }
            if(i>1)
            {
                ans = max(ans, abs(a[i] - a[i - 1]));
            }

        }
        printf("%d %d\n", ans, sum);
    }
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <string.h>
using namespace std;
int a[400005];

int main()
{
    int t;
    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        double sum=0;
        int  num=0, maxn=0,pos=0,maxnum=0,m=0,k=0,minnum=1000000005;
        a[0] = -1,a[n]=-1;
        for (int i = 1; i <= n;i++)
        {
            cin >> a[i];
            if(a[i]!=-1&&a[i-1]!=-1)
            {
                if(abs(a[i]-a[i-1])>maxn)
                {
                	maxn=abs(a[i]-a[i-1]);
                	pos=i;
				}
            }
        }
		if(a[1]!=-1&&a[2]==-1)
		{

                num++;
                maxnum = max(maxnum, a[1]);
                minnum=min(minnum,a[1]);
		}
			if(a[n]!=-1&&a[n-1]==-1)
		{

                num++;
                maxnum = max(maxnum, a[n]);
                minnum=min(minnum,a[n]);
		}
        for (int i = 2; i <= n-1;i++)
        {

            if(a[i]!=-1&&(a[i-1]==-1||a[i+1]==-1))
            {

                num++;
                maxnum = max(maxnum, a[i]);
                minnum=min(minnum,a[i]);
            }
        }
        if(num==0)
        {
        	printf("0 0\n");
        	continue;
		}
		sum=(maxnum+minnum)/2;
        int x1=max(maxnum-sum,sum-minnum);
        if(x1>=maxn)
        {

            	m=x1;
            	k=sum;

        }
        else
        {
             m = maxn;
             k = a[pos];
        }
        printf("%d %d\n", m, k);
    }
        return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
ll a[100010];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		ll maxx=-10;
		ll minn=INF-10;
		int sum=0;
		for(int i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
			if(a[i]!=-1){
				sum++;
			maxx=max(maxx,a[i]);
			minn=min(minn,a[i]);
			}
		}
		if(sum<2)
		{
			if(sum==0)
			{
				printf("%d %d\n",0,0);
			}
			else
			{
				printf("%d %lld\n",0,minn);
			}
		}
		else
		{
			ll u=minn;
			ll uu=maxx;
			ll oo=uu-u;
			ll y;
			if(oo%2==0){
				y=oo/2;
				ll ans=u+y;
				ll ans1=0;
			//printf("%d\n",ans);
			for(int i=0;i<n-1;i++)
			{
				if(a[i]==-1)
				{
					a[i]=ans;
				}
				if(a[i+1]==-1)
				{
					a[i+1]=ans;
				}
				ans1=max(ans1,abs(a[i+1]-a[i]));
			}
			printf("%lld %lld\n",ans1,ans);
			}
			else{
				y=oo/2+1;
				ll ans=u+y;
				ll ans1=u+y-1;
				ll t1=0;
				ll t2=0;
				for(int i=0;i<n-1;i++)
				{
					if(a[i]==-1)
					{
						a[i]=ans;
					}
					if(a[i+1]==-1)
					{
						a[i+1]=ans;
					}
					t1=max(t1,abs(a[i+1]-a[i]));
				}
				for(int i=0;i<n-1;i++)
				{
					if(a[i]==-1)
					{
						a[i]=ans1;
					}
					if(a[i+1]==-1)
					{
						a[i+1]=ans1;
					}
					t2=max(t2,abs(a[i+1]-a[i]));
				}
				if(t1<t2)
				{
					printf("%lld %lld\n",t1,ans);
				}
				else
				{
					printf("%lld %lld\n",t2,ans1);
				}
			}

		}
	}
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
ll a[100010];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		ll maxx=-10;
		ll minn=INF-10;
		int sum=0;
		ll r=0;
		for(int i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
			if(a[i]!=-1){
				sum++;
				r=a[i];
			}
		}
		if(sum<2)
		{
			if(sum==0)
			{
				printf("%d %d\n",0,0);
			}
			else
			{
				printf("%d %lld\n",0,r);
			}
		}
		else
		{
			for(int i=0;i<n;i++)
			{
				if(i==0)
				{
					if(a[i]!=-1&&a[i+1]==-1)
					{
						maxx=max(maxx,a[i]);
						minn=min(minn,a[i]);
					}
				}
				else if(i==n-1)
				{
					if(a[i-1]==-1&&a[n-1]!=-1)
					{
						maxx=max(maxx,a[i]);
						minn=min(minn,a[i]);
					}
				}
				else
				{
					if((a[i-1]==-1||a[i+1]==-1)&&a[i]!=-1)
					{
						maxx=max(maxx,a[i]);
						minn=min(minn,a[i]);
					}
				}
			 }
			ll u=minn;
			ll uu=maxx;
			ll oo=uu-u;
			ll y;
			if(oo%2==0){
				y=oo/2;
				ll ans=u+y;
				ll ans1=0;
			//printf("%d\n",ans);
			for(int i=0;i<n-1;i++)
			{
				if(a[i]==-1)
				{
					a[i]=ans;
				}
				if(a[i+1]==-1)
				{
					a[i+1]=ans;
				}
				ans1=max(ans1,abs(a[i+1]-a[i]));
			}
			printf("%lld %lld\n",ans1,ans);
			}
			else{
				y=oo/2+1;
				ll ans=u+y;
				ll ans1=u+y-1;
				ll t1=0;
				ll t2=0;
				for(int i=0;i<n-1;i++)
				{
					if(a[i]==-1)
					{
						a[i]=ans;
					}
					if(a[i+1]==-1)
					{
						a[i+1]=ans;
					}
					t1=max(t1,abs(a[i+1]-a[i]));
				}
				for(int i=0;i<n-1;i++)
				{
					if(a[i]==-1)
					{
						a[i]=ans1;
					}
					if(a[i+1]==-1)
					{
						a[i+1]=ans1;
					}
					t2=max(t2,abs(a[i+1]-a[i]));
				}
				if(t1<t2)
				{
					printf("%lld %lld\n",t1,ans);
				}
				else
				{
					printf("%lld %lld\n",t2,ans1);
				}
			}

		}
	}
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
ll a[100010];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		ll maxx=-10;
		ll minn=INF-10;
		int sum=0;
		for(int i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
			if(a[i]!=-1){
				sum++;
			maxx=max(maxx,a[i]);
			minn=min(minn,a[i]);
			}
		}
		if(sum<2)
		{
			if(sum==0)
			{
				printf("%d %d\n",0,0);
			}
			else
			{
				printf("%d %lld\n",0,minn);
			}
		}
		else
		{
			ll u=minn;
			ll uu=maxx;
			ll oo=uu-u;
			ll y;
			if(oo%2==0)
				y=oo/2;
			else
				y=oo/2+1;
			ll ans=u+y;
			ll ans1=0;
			//printf("%d\n",ans);
			for(int i=0;i<n-1;i++)
			{
				if(a[i]==-1)
				{
					a[i]=ans;
				}
				if(a[i+1]==-1)
				{
					a[i+1]=ans;
				}
				ans1=max(ans1,abs(a[i+1]-a[i]));
			}
			printf("%lld %lld\n",ans1,ans);
		}
	}
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cstring>
#include<cmath>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
ll a[100010];
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		int n;
		scanf("%d",&n);
		ll maxx=-10;
		ll minn=INF-10;
		int sum=0;
		for(int i=0;i<n;i++)
		{
			scanf("%lld",&a[i]);
			if(a[i]!=-1){
				sum++;
			maxx=max(maxx,a[i]);
			minn=min(minn,a[i]);
			}
		}
		if(sum<2)
		{
			if(sum==0)
			{
				printf("%d %d\n",0,0);
			}
			else
			{
				printf("%d %d\n",0,minn);
			}
		}
		else
		{
			ll u=minn;
			ll uu=maxx;
			ll oo=uu-u;
			ll y;
			if(oo%2==0)
				y=oo/2;
			else
				y=oo/2+1;
			ll ans=u+y;
			ll ans1=0;
			//printf("%d\n",ans);
			for(int i=0;i<n-1;i++)
			{
				if(a[i]==-1)
				{
					a[i]=ans;
				}
				if(a[i+1]==-1)
				{
					a[i+1]=ans;
				}
				ans1=max(ans1,abs(a[i+1]-a[i]));
			}
			printf("%lld %lld\n",ans1,ans);
		}
	}
}


#include<iostream>
#include<algorithm>
#include<string>
void solve();

using namespace std;
int main()
{
     long long int t;
     cin>>t;
     while(t--)
     {

          solve();

     }

}
void solve()
{
     long long int i,j,n,max=0,min=100000000,k,max1=0;
          cin>>n;
          long long int a[400000];
          for(i=0;i<n;i++)
          {
               cin>>a[i];
          }
          for(i=0;i<n;i++)
          {
               if(i==0)
               {
               if(a[i+1]==-1&&a[i]!=-1)
               {
                    if(a[i]<min)
                    {
                         min=a[i];
                    }
                    if(a[i]>max)
                    {
                         max=a[i];
                    }
               }
               continue;
               }
               if(i==n-1)
               {
               if(a[i-1]==-1&&a[i]!=-1)
               {
                    if(a[i]<min)
                    {
                         min=a[i];
                    }
                    if(a[i]>max)
                    {
                         max=a[i];
                    }
               }
               continue;
               }
               if((a[i-1]==-1||a[i+1]==-1)&&(a[i]!=-1))
               {
                    if(a[i]<min)
                    {
                         min=a[i];
                    }
                    if(a[i]>max)
                    {
                         max=a[i];
                    }
               }
          }
          for(i=0;i<n-1;i++)
          {
               if(a[i+1]!=-1&&a[i]!=-1)
               {
                    if(abs(a[i+1]-a[i])>max1)
                    {
                         max1=abs(a[i+1]-a[i]);
                    }
               }
          }

          k=(max-min)/2;
          if(max1>=k)
          {
               k=max1;
          }
          cout<<k<<" ";
          if(max-k>=k-min)
          {
               max=max-k;
          }
          else
          {
               max=k-min;
          }

               cout<<max<<endl;

}


#include<iostream>
#include<algorithm>
#include<string>
void solve();

using namespace std;
int main()
{
     long long int t;
     cin>>t;
     while(t--)
     {

          solve();

     }

}
void solve()
{
     long long int i,j,n,max=0,min=100000000,k,max1=0;
          cin>>n;
          long long int a[n];
          for(i=0;i<n;i++)
          {
               cin>>a[i];
          }
          for(i=0;i<n;i++)
          {
               if(i==0)
               {
               if(a[i+1]==-1&&a[i]!=-1)
               {
                    if(a[i]<min)
                    {
                         min=a[i];
                    }
                    if(a[i]>max)
                    {
                         max=a[i];
                    }
               }
               continue;
               }
               if(i==n-1)
               {
               if(a[i-1]==-1&&a[i]!=-1)
               {
                    if(a[i]<min)
                    {
                         min=a[i];
                    }
                    if(a[i]>max)
                    {
                         max=a[i];
                    }
               }
               continue;
               }
               if((a[i-1]==-1||a[i+1]==-1)&&(a[i]!=-1))
               {
                    if(a[i]<min)
                    {
                         min=a[i];
                    }
                    if(a[i]>max)
                    {
                         max=a[i];
                    }
               }
          }
          for(i=0;i<n-1;i++)
          {
               if(a[i+1]!=-1&&a[i]!=-1)
               {
                    if(abs(a[i+1]-a[i])>max1)
                    {
                         max1=abs(a[i+1]-a[i]);
                    }
               }
          }

          k=(max-min)/2;
          if(max1>=k)
          {
               k=max1;
          }
          cout<<k<<" ";
          if(max-k>=k-min)
          {
               max=max-k;
          }
          else
          {
               max=k-min;
          }

               cout<<max<<endl;

}


#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include<string>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
int arr[100001];

int myabs(int x) {
	return x > 0 ? x : (-1 * x);
}

int main() {
	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(false);

	int t;
	cin >> t;
	while (t--) {
		int m = 0, k;
		cin >> n;
		int big = -1;
		int small = 1e9+1;
		for (int i = 1; i <= n; i++) {
			cin >> arr[i];
		}
		for (int i = 1; i <= n; i++)
			if (arr[i] == -1) {
				if (i - 1 > 0 && arr[i - 1] != -1) {
					big = max(big, arr[i - 1]);
					small = min(small, arr[i - 1]);
				}
				if (i + 1 <= n && arr[i + 1] != -1) {
					big = max(big, arr[i + 1]);
					small = min(small, arr[i + 1]);
				}
			}
		if (big == -1 && small == 1e9 + 1) {
			cout << "0 0\n";
		}
		else {
			k = (big + small) / 2;

			for (int i = 1; i <= n; i++)
				if (arr[i] == -1)
					arr[i] = k;
			for (int i = 1; i < n; i++)
				m = max(myabs(arr[i] - arr[i + 1]), m);
			cout << m << " " << k << "\n";
		}
	}

}


#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <unordered_set>

using namespace std;

int main() {
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		cin >> n;
		vector<int> a(n,-1);
		int diff = 0;
		int maxA = -1;
		int minA = INT_MAX;
		bool all = true;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
			if (a[i] != -1)
				all = false;
			if (i > 0) {
				if (a[i] != -1 && a[i - 1] != -1) {
					diff = max(diff, abs(a[i] - a[i - 1]));
				}
				if (a[i] == -1) {
					if (a[i - 1] != -1) {
						maxA = max(maxA, a[i - 1]);
						minA = min(minA, a[i - 1]);
					}
				}
				if (a[i] != -1 && a[i - 1] == -1) {
					maxA = max(maxA, a[i]);
					minA = min(minA, a[i]);
				}
			}

		}
		if (all) {
			cout << 0 << " " << 0 << endl;
			continue;
		}
		int k = minA + (maxA - minA) / 2;
		int m = max(maxA - k, k - minA);
		if (m >= diff) {
			cout << m << " " << k << endl;
		}
		else {
			cout << diff << " " << k << endl;
		}

	}
	return 0;
}


#include <iostream>
#include <string>

using namespace std;
int t, n;
int *a;

long long max(long long a1, long long a2) { if (a1 > a2) return a1; else return a2; }
long long min(long long a1, long long a2) { if (a1 < a2) return a1; else return a2; }
long long absl(long long a1) { if (a1 < 0) return -a1; else return a1; }

int main()
{
	cin >> t;
	a = new int[100005];
	for (int i = 0; i < t; i++)
	{
		cin >> n;
		int m = 0, k = 0;
		for (int j = 0; j < n; j++)
			cin >> a[j];

		int start = 1000000001; int finish = -2;

		for (int j = 0; j < n - 1; j++)
		{
			int aa = -2;
			if (a[j] != -1 && a[j + 1] == -1)
				aa = a[j];
			if (a[j] == -1 && a[j + 1] != -1)
				aa = a[j + 1];
			if (aa != -2)
			{
				start = min(start, aa);
				finish = max(finish, aa);
			}
		}
		if (start == 1000000001 && finish == -2)
		{
			k = 0;
		}
		else if (start == 1000000001)
		{
			k = finish;
		}
		else if (finish == -2)
		{
			k = start;
		}
		else
		{
			k = (finish + start) / 2;
		}

		for (int j = 0; j < n - 1; j++)
		{
			if (a[j] == -1)
				a[j] = k;
			if (a[j + 1] == -1)
				a[j + 1] = k;
			m = max(m, absl(a[j] - a[j + 1]));
		}
		cout << m << " " << k << endl;
	}
	//system("pause");
	return 0;
}


#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<climits>
#include<cmath>
#include<map>
#include<set>
#include<deque>
using namespace std;
const int maxn = 1e5 + 10;
int arr[maxn];
int main()
{
	ios_base::sync_with_stdio(false);
	int T;
	cin >> T;
	while (T--)
	{
		int N;
		cin >> N;
		for (int i = 1; i <= N; i++)
		{
			cin >> arr[i];
		}
		int temp = 0;
		int u = -1, d = INT_MAX;
		for (int i = 1; i <= N; i++)
		{
			if (arr[i] == -1)
			{
				if (i != N)
				{
					if (arr[i + 1] != -1)
					{
						u = max(u, arr[i + 1]);
						d = min(d, arr[i + 1]);
					}
				}
				if (i != 1)
				{
					if (arr[i - 1] != -1)
					{
						u = max(u, arr[i - 1]);
						d = min(d, arr[i - 1]);
					}
				}
			}
		}
		for (int i = 2; i <= N; i++)
		{
			if (arr[i] != -1 && arr[i - 1] != -1)
				temp = max(temp, abs(arr[i] - arr[i - 1]));
		}
		if (u == -1 && d == INT_MAX)
			u = 0, d = 0;
		int ans = max((u - d + 1) / 2, temp);
		cout << ans << " " << (u - d) / 2 + d << "\n";

	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

void solve() {
	std::vector<int> v;
	int n, a, min = std::numeric_limits<int>::max(), max = -1, ans = 0;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		v.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		if (i > 0 && v[i] == -1 && v[i - 1] != -1) {
			max = std::max(max, v[i-1]);
			min = std::min(min, v[i-1]);
		}
		if (i < n - 1 && v[i] == -1 && v[i + 1] != -1) {
			max = std::max(max, v[i+1]);
			min = std::min(min, v[i+1]);
		}
	}

	if (max != -1) ans = (min + max) / 2;

	int m = 0;
	for (int i = 0; i < n - 1; i++) {
		if (v[i] == -1) v[i] = ans;
		if (v[i+1] == -1) v[i+1] = ans;
		m = std::max(m, std::abs(v[i] - v[i+1]));
	}
	std::cout << m << ' ' << ans << std::endl;
}

int main() {
	int t;
	std::cin >> t;
	while (t--) solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

void solve() {
	std::vector<int> v;
	int n, a, min = std::numeric_limits<int>::max(), max = -1, ans = 0;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		v.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		if (i > 0 && v[i] == -1 && v[i - 1] != -1) {
			max = std::max(max, v[i-1]);
			min = std::min(min, v[i-1]);
		}
		if (i < n - 1 && v[i] == -1 && v[i + 1] != -1) {
			max = std::max(max, v[i+1]);
			min = std::min(min, v[i+1]);
		}
	}

	if (max != -1) ans = (min + max) / 2;

	for (int i = 0; i < n; i++) {
		if (v[i] == -1) v[i] = ans;
	}
	int m = 0;
	for (int i = 0; i < n - 1; i++) {
		m = std::max(m, std::abs(v[i] - v[i+1]));
	}
	std::cout << m << ' ' << ans << std::endl;
}

int main() {
	int t;
	std::cin >> t;
	while (t--) solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

void solve() {
	std::vector<int> v;
	int n, a, ans = -1, temp;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		v.push_back(a);
	}
	if (n == 1) {
		std::cout << 0 << ' ' << 0 << std::endl;
		return;
	}
	else if (n == 2) {
		std::cout << 0 << ' ' << std::max({v[0], v[1], 0}) << std::endl;
		return;
	}
	else {
		for (int i = 1; i < n - 1; i++) {
			if (v[i] == -1 && v[i - 1] != -1 && v[i + 1] != -1) {
				ans = std::ceil(std::abs((v[i-1] + v[i+1]) / 2.0));
			}
			else if (v[i] != -1 && (v[i - 1] == -1 || v[i + 1] == -1)) {
				temp = v[i];
			}
		}
	}
	if (ans == -1) {
		ans = temp;
		for (int i = 0; i < n; i++) {
			if (v[i] == -1) v[i] = ans;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (v[i] == -1) v[i] = ans;
		}
	}
	int m = -1;
	for (int i = 0; i < n - 1; i++) {
		m = std::max(m, std::abs(v[i] - v[i+1]));
	}
	std::cout << m << ' ' << ans << std::endl;
}

int main() {
	int t;
	std::cin >> t;
	while (t--) solve();
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

void solve() {
	std::vector<int> v;
	int n, a, min = std::numeric_limits<int>::max(), max = -1, ans = 0;
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		if (a != -1) {
			min = std::min(min, a);
			max = std::max(max, a);
		}
		v.push_back(a);
	}
	if (max != -1) ans = (min + max) / 2;

	for (int i = 0; i < n; i++) {
		if (v[i] == -1) v[i] = ans;
	}
	int m = 0;
	for (int i = 0; i < n - 1; i++) {
		m = std::max(m, std::abs(v[i] - v[i+1]));
	}
	std::cout << m << ' ' << ans << std::endl;
}

int main() {
	int t;
	std::cin >> t;
	while (t--) solve();
	return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;
const double PI = 3.141592653589793;

template < template <typename> class Array, typename T >
void outArray(Array<T>& a) {
	auto it = a.begin();
	for (; it != a.end(); it++) {
		cout << (*it) << " ";
	}
	cout << "\n";
}

template<typename T>
void outVector(vector<T>& a) {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i] << " ";
	}
	cout << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		int temp = 0;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		long long maxDiff = -1;
		int ans = 0;
		long long x = 1e18, y = -1;
		for (int i = 0; i < n; i++) {
			if (i > 0 && a[i] >= 0 && a[i - 1] >= 0) {
				if (abs(a[i] - a[i - 1]) > maxDiff) {
					ans = a[i];
					maxDiff = abs(a[i] - a[i - 1]);
				}
			}
			else {
				if (a[i] == -1) {
					if (i > 0 && a[i - 1] != -1) {
						x = min(x, a[i - 1]);
						y = max(y, a[i - 1]);
					}
					if (i < n - 1 && a[i + 1] != -1) {
						y = max(y, a[i + 1]);
						x = min(x, a[i + 1]);
					}
				}
			}
		}

		if (y == -1 || maxDiff > (y - x) / 2 && maxDiff != -1) {
			if (maxDiff == -1) {
				maxDiff = 0;
			}
			cout << maxDiff << " " << ans << "\n";
		}
		else {
			cout << (y - x) / 2 << " " << (y + x) / 2 << "\n";
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;
const double PI = 3.141592653589793;

template < template <typename> class Array, typename T >
void outArray(Array<T>& a) {
	auto it = a.begin();
	for (; it != a.end(); it++) {
		cout << (*it) << " ";
	}
	cout << "\n";
}

template<typename T>
void outVector(vector<T>& a) {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i] << " ";
	}
	cout << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		int temp = 0;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		long long maxDiff = -1;
		long long x = 1e18, y = -1;
		for (int i = 0; i < n; i++) {
			if (i > 0 && a[i] >= 0 && a[i - 1] >= 0) {
				if (abs(a[i] - a[i - 1]) > maxDiff) {
					maxDiff = abs(a[i] - a[i - 1]);
				}
			}
			else {
				if (a[i] == -1) {
					if (i > 0 && a[i - 1] != -1) {
						x = min(x, a[i - 1]);
						y = max(y, a[i - 1]);
					}
					if (i < n - 1 && a[i + 1] != -1) {
						y = max(y, a[i + 1]);
						x = min(x, a[i + 1]);
					}
				}
			}
		}
		//cout << x << " " << y << "\n";
		if (y == -1 || maxDiff > y - (y + x) / 2 && maxDiff != -1) {
			if (maxDiff == -1) {
				maxDiff = 0;
			}
			if (y == -1) {
				y = 0;
				x = 0;
			}
			cout << maxDiff << " " << y - (y + x) / 2 << "\n";
		}
		else {
			cout << y - (y + x) / 2 << " " << (y + x) / 2 << "\n";
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;
const double PI = 3.141592653589793;

template < template <typename> class Array, typename T >
void outArray(Array<T>& a) {
	auto it = a.begin();
	for (; it != a.end(); it++) {
		cout << (*it) << " ";
	}
	cout << "\n";
}

template<typename T>
void outVector(vector<T>& a) {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i] << " ";
	}
	cout << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		int temp = 0;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		long long maxDiff = -1;
		long long x = 1e18, y = -1;
		for (int i = 0; i < n; i++) {
			if (i > 0 && a[i] >= 0 && a[i - 1] >= 0) {
				if (abs(a[i] - a[i - 1]) > maxDiff) {
					maxDiff = abs(a[i] - a[i - 1]);
				}
			}
			else {
				if (a[i] == -1) {
					if (i > 0 && a[i - 1] != -1) {
						x = min(x, a[i - 1]);
						y = max(y, a[i - 1]);
					}
					if (i < n - 1 && a[i + 1] != -1) {
						y = max(y, a[i + 1]);
						x = min(x, a[i + 1]);
					}
				}
			}
		}
		//cout << x << " " << y << "\n";
		if (y == -1 || maxDiff > y - (y + x) / 2 && maxDiff != -1) {
			if (maxDiff == -1) {
				maxDiff = 0;
			}
			cout << maxDiff << " " << y - (y + x) / 2 << "\n";
		}
		else {
			cout << y - (y + x) / 2 << " " << (y + x) / 2 << "\n";
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;
const double PI = 3.141592653589793;

template < template <typename> class Array, typename T >
void outArray(Array<T>& a) {
	auto it = a.begin();
	for (; it != a.end(); it++) {
		cout << (*it) << " ";
	}
	cout << "\n";
}

template<typename T>
void outVector(vector<T>& a) {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i] << " ";
	}
	cout << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		int temp = 0;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		long long maxDiff = -1;
		long long x = 1e18, y = -1;
		for (int i = 0; i < n; i++) {
			if (i > 0 && a[i] >= 0 && a[i - 1] >= 0) {
				if (abs(a[i] - a[i - 1]) > maxDiff) {
					maxDiff = abs(a[i] - a[i - 1]);
				}
			}
			else {
				if (a[i] == -1) {
					if (i > 0 && a[i - 1] != -1) {
						x = min(x, a[i - 1]);
						y = max(y, a[i - 1]);
					}
					if (i < n - 1 && a[i + 1] != -1) {
						y = max(y, a[i + 1]);
						x = min(x, a[i + 1]);
					}
				}
			}
		}
		//cout << x << " " << y << "\n";
		if (y == -1 || maxDiff > y - (y + x) / 2 && maxDiff != -1) {
			if (maxDiff == -1) {
				maxDiff = 0;
			}
			if (y == -1) {
				y = 0;
				x = 0;
			}
			cout << maxDiff << " " << (y + x) / 2 << "\n";
		}
		else {
			cout << y - (y + x) / 2 << " " << (y + x) / 2 << "\n";
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
using namespace std;
const double PI = 3.141592653589793;

template < template <typename> class Array, typename T >
void outArray(Array<T>& a) {
	auto it = a.begin();
	for (; it != a.end(); it++) {
		cout << (*it) << " ";
	}
	cout << "\n";
}

template<typename T>
void outVector(vector<T>& a) {
	for (int i = 0; i < a.size(); i++) {
		cout << a[i] << " ";
	}
	cout << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		vector<long long> a(n);
		int temp = 0;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			cin >> a[i];
		}
		long long maxDiff = -1;
		int ans = 0;
		long long x = 1e18, y = -1;
		for (int i = 0; i < n; i++) {
			if (i > 0 && a[i] >= 0 && a[i - 1] >= 0) {
				if (abs(a[i] - a[i - 1]) > maxDiff) {
					ans = a[i];
					maxDiff = abs(a[i] - a[i - 1]);
				}
			}
			else {
				if (a[i] == -1) {
					if (i > 0 && a[i - 1] != -1) {
						x = min(x, a[i - 1]);
						y = max(y, a[i - 1]);
					}
					if (i < n - 1 && a[i + 1] != -1) {
						y = max(y, a[i + 1]);
						x = min(x, a[i + 1]);
					}
				}
			}
		}

		if (y == -1 || maxDiff > (y - x) / 2 && maxDiff != -1) {
			if (maxDiff == -1) {
				maxDiff = 0;
			}
			cout << maxDiff << " " << ans << "\n";
		}
		else {
			cout << y - (y + x) / 2 << " " << (y + x) / 2 << "\n";
		}
	}
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(1000000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int kk;
		cin >> kk;

		int smallestNumber = INT_MAX;
		int largestNumber = INT_MIN;
		for (int i = 0; i < kk; ++i) cin >> arr[i];
		for (int i = 0; i < kk-1; ++i) {
			if (arr.at(i) != -1) {
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
				if (smallestNumber > arr[i+1]) smallestNumber = arr[i+1];
				if (largestNumber < arr[i+1]) largestNumber = arr[i+1];
			}
		}

		int k = (largestNumber + smallestNumber)/2;
		int m = 0;
		for (int i = 0; i < kk-1; ++i) {
			if (arr[i] == -1) arr[i] = k;
			if (arr[i+1] == -1) arr[i+1] = k;
			m = max(abs(arr[i]-arr[i+1]), m);
		}
		cout << m << " " << k << "\n";
	}
	//getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(1000000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int kk;
		cin >> kk;

		int smallestNumber = INT_MAX;
		int largestNumber = INT_MIN;
		for (int i = 0; i < kk; ++i) cin >> arr[i];
		for (int i = 0; i < kk-1; ++i) {
			if (arr.at(i) != -1) {
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
				if (smallestNumber > arr[i+1]) smallestNumber = arr[i+1];
				if (largestNumber < arr[i+1]) largestNumber = arr[i+1];
			}
		}

		int k = (largestNumber + smallestNumber)/2;
		int m = 0;
		for (int i = 0; i < kk-1; ++i) {
			if (arr[i] == -1) arr[i] = k;
			if (arr[i+1] == -1) arr[i+1] = k;
			m = max(abs(arr[i]-arr[i+1]), m);
		}
		cout << m << " " << k << "\n";
	}
	getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(400000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int kk;
		cin >> kk;

		int smallestNumber = INT_MAX;
		int largestNumber = INT_MIN;
		int maxDiff = INT_MIN;
		int count = 0;
		ull maximum = 0;
		bool allMinus = true;
		bool alreadyHasMinimal = false;
		int oneOfTheNumbers = -1;
		for (int i = 0; i < kk; ++i) cin >> arr[i];
		for (int i = 0; i < kk-1; ++i) {
			if (arr.at(i) != -1 && arr.at(i + 1) != -1) {
				int diff = abs(arr[i] - arr[i + 1]);
				if (maxDiff < diff) maxDiff = diff;
				alreadyHasMinimal = true;
				oneOfTheNumbers = arr[i];
			}
			if (arr.at(i) != -1) {
				allMinus = false;
				maximum += arr.at(i);
				count += 1;
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
			}
		}
		if (arr.at(kk-1) != -1) {
			count += 1;
			allMinus = false;
			maximum += arr.at(kk-1);
			if (smallestNumber > arr[kk-1]) smallestNumber = arr[kk-1];
			if (largestNumber < arr[kk-1]) largestNumber = arr[kk-1];
		}

		if (allMinus) {
			cout << "0 0\n";
		}
		else {
			ull k = maximum / count;
			ull m = max(k - smallestNumber, largestNumber - k);
			if (alreadyHasMinimal && m < maxDiff){
				m = maxDiff;
			}
			cout << m << " " << k << "\n";
		}
	}

	getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(400000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int k;
		cin >> k;

		int smallestNumber = INT_MAX;
		int largestNumber = INT_MIN;
		int maxDiff = INT_MIN;
		int count = 0;
		ull maximum = 0;
		bool allMinus = true;
		bool alreadyHasMinimal = false;
		int oneOfTheNumbers = -1;
		for (int i = 0; i < k; ++i) cin >> arr[i];
		for (int i = 0; i < k-1; ++i) {
			if (arr.at(i) != -1 && arr.at(i + 1) != -1) {
				int diff = abs(arr[i] - arr[i + 1]);
				if (maxDiff < diff) maxDiff = diff;
				alreadyHasMinimal = true;
				oneOfTheNumbers = arr[i];
			}
			if (arr.at(i) != -1) {
				allMinus = false;
				maximum += arr.at(i);
				count += 1;
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
				allMinus = false;
				maximum += arr.at(i+1);
				count += 1;
				if (smallestNumber > arr[i+1]) smallestNumber = arr[i+1];
				if (largestNumber < arr[i+1]) largestNumber = arr[i+1];
			}
		}

		if (allMinus) {
			cout << "0 0\n";
		}
		else {
			ull k = maximum / count;
			ull m = max(k - smallestNumber, largestNumber - k);
			if (alreadyHasMinimal && m < maxDiff){
				m = maxDiff;
			}
			cout << m << " " << k << "\n";
		}
	}

	getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(400000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int k;
		cin >> k;

		int smallestNumber = INT_MAX;
		int largestNumber = INT_MIN;
		int maxDiff = INT_MIN;
		int count = 0;
		ull maximum = 0;
		bool allMinus = true;
		bool alreadyHasMinimal = false;
		int oneOfTheNumbers = -1;
		for (int i = 0; i < k; ++i) cin >> arr[i];
		for (int i = 0; i < k-1; ++i) {
			if (arr.at(i) != -1 && arr.at(i + 1) != -1) {
				int diff = abs(arr[i] - arr[i + 1]);
				if (maxDiff < diff) maxDiff = diff;
				alreadyHasMinimal = true;
				oneOfTheNumbers = arr[i];
			}
			if (arr.at(i) != -1) {
				allMinus = false;
				maximum += arr.at(i);
				count += 1;
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
				allMinus = false;
				maximum += arr.at(i+1);
				count += 1;
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
		}

		if (allMinus) {
			cout << "0 0\n";
		}
		else {
			ull k = maximum / count;
			ull m = min(k - smallestNumber, largestNumber - k);
			if (alreadyHasMinimal && m < maxDiff){
				m = maxDiff;
			}
			cout << m << " " << k << "\n";
		}
	}

	getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(1000000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int kk;
		cin >> kk;

		ull smallestNumber = LLONG_MAX;
		ull largestNumber = LLONG_MIN;
		ull maxDiff = LLONG_MIN;
		int count = 0;
		bool allMinus = true;
		bool alreadyHasMinimal = false;
		int oneOfTheNumbers = -1;
		for (int i = 0; i < kk; ++i) cin >> arr[i];
		for (int i = 0; i < kk-1; ++i) {
			if (arr.at(i) != -1 && arr.at(i + 1) != -1) {
				int diff = abs(arr[i] - arr[i + 1]);
				if (maxDiff < diff) maxDiff = diff;
				alreadyHasMinimal = true;
				oneOfTheNumbers = arr[i];
			}
			if (arr.at(i) != -1) {
				allMinus = false;
				count += 1;
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
			}
		}
		if (arr.at(kk-1) != -1) {
			allMinus = false;
			count += 1;
			if (smallestNumber > arr[kk-1]) smallestNumber = arr[kk-1];
			if (largestNumber < arr[kk-1]) largestNumber = arr[kk-1];
		}

		if (allMinus) {
			cout << "0 0\n";
		}
		else {
			ull k = (largestNumber + smallestNumber)/2;
			int m = 0;
			for (int i = 0; i < kk-1; ++i) {
				if (arr[i] == -1) arr[i] = k;
				if (arr[i+1] == -1) arr[i+1] = k;
				m = max(abs(arr[i]-arr[i+1]), m);
			}
			cout << m << " " << k << "\n";
		}
	}

	getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(1000000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int kk;
		cin >> kk;

		int smallestNumber = INT_MAX;
		int largestNumber = INT_MIN;
		for (int i = 0; i < kk; ++i) cin >> arr[i];
		for (int i = 0; i < kk; ++i) {
			if (arr.at(i) != -1 && i-1 >= 0 && arr.at(i-1) == -1){
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i) != -1 && i+1 <= kk-1 && arr.at(i+1) == -1){
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
		}

		int k = (largestNumber + smallestNumber)/2;
		int m = 0;
		for (int i = 0; i < kk-1; ++i) {
			if (arr[i] == -1) arr[i] = k;
			if (arr[i+1] == -1) arr[i+1] = k;
			m = max(abs(arr[i]-arr[i+1]), m);
		}
		cout << m << " " << k << "\n";
	}
	//getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(400000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int k;
		cin >> k;

		int smallestNumber = INT_MAX;
		int largestNumber = INT_MIN;
		int maxDiff = INT_MIN;
		int count = 0;
		ull maximum = 0;
		bool allMinus = true;
		bool alreadyHasMinimal = false;
		int oneOfTheNumbers = -1;
		for (int i = 0; i < k; ++i) cin >> arr[i];
		for (int i = 0; i < k-1; ++i) {
			if (arr.at(i) != -1 && arr.at(i + 1) != -1) {
				int diff = abs(arr[i] - arr[i + 1]);
				if (maxDiff < diff) maxDiff = diff;
				alreadyHasMinimal = true;
				oneOfTheNumbers = arr[i];
			}
			if (arr.at(i) != -1) {
				allMinus = false;
				maximum += arr.at(i);
				count += 1;
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
				allMinus = false;
				maximum += arr.at(i+1);
				count += 1;
				if (smallestNumber > arr[i+1]) smallestNumber = arr[i+1];
				if (largestNumber < arr[i+1]) largestNumber = arr[i+1];
			}
		}

		if (allMinus) {
			cout << "0 0\n";
		}
		else {
			ull k = maximum / count;
			ull m = min(k - smallestNumber, largestNumber - k);
			if (alreadyHasMinimal && m < maxDiff){
				m = maxDiff;
			}
			cout << m << " " << k << "\n";
		}
	}

	getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(400000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int kk;
		cin >> kk;

		int smallestNumber = INT_MAX;
		int largestNumber = INT_MIN;
		int maxDiff = INT_MIN;
		int count = 0;
		ull maximum = 0;
		bool allMinus = true;
		bool alreadyHasMinimal = false;
		int oneOfTheNumbers = -1;
		for (int i = 0; i < kk; ++i) cin >> arr[i];
		for (int i = 0; i < kk-1; ++i) {
			if (arr.at(i) != -1 && arr.at(i + 1) != -1) {
				int diff = abs(arr[i] - arr[i + 1]);
				if (maxDiff < diff) maxDiff = diff;
				alreadyHasMinimal = true;
				oneOfTheNumbers = arr[i];
			}
			if (arr.at(i) != -1) {
				allMinus = false;
				maximum += arr.at(i);
				count += 1;
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
			}
		}
		if (arr.at(kk-1) != -1) {
			allMinus = false;
			maximum += arr.at(kk-1);
			count += 1;
			if (smallestNumber > arr[kk-1]) smallestNumber = arr[kk-1];
			if (largestNumber < arr[kk-1]) largestNumber = arr[kk-1];
		}

		if (allMinus) {
			cout << "0 0\n";
		}
		else {
			ull k = (largestNumber + smallestNumber)/2;
			ull m = max(k - smallestNumber, largestNumber - k);
			if (alreadyHasMinimal && m < maxDiff){
				m = maxDiff;
			}
			cout << m << " " << k << "\n";
		}
	}

	getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(1000000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int kk;
		cin >> kk;

		ull smallestNumber = LLONG_MAX;
		ull largestNumber = LLONG_MIN;
		for (int i = 0; i < kk; ++i) cin >> arr[i];
		for (int i = 0; i < kk-1; ++i) {
			if (arr.at(i) != -1) {
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
				if (smallestNumber > arr[i+1]) smallestNumber = arr[i+1];
				if (largestNumber < arr[i+1]) largestNumber = arr[i+1];
			}
		}
		if (arr.at(kk-1) != -1) {
			if (smallestNumber > arr[kk-1]) smallestNumber = arr[kk-1];
			if (largestNumber < arr[kk-1]) largestNumber = arr[kk-1];
		}

		ull k = (largestNumber + smallestNumber)/2;
		int m = 0;
		for (int i = 0; i < kk-1; ++i) {
			if (arr[i] == -1) arr[i] = k;
			if (arr[i+1] == -1) arr[i+1] = k;
			m = max(abs(arr[i]-arr[i+1]), m);
		}
		cout << m << " " << k << "\n";
	}

	getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(400000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int kk;
		cin >> kk;

		ull smallestNumber = LLONG_MAX;
		ull largestNumber = LLONG_MIN;
		ull maxDiff = LLONG_MIN;
		int count = 0;
		bool allMinus = true;
		bool alreadyHasMinimal = false;
		int oneOfTheNumbers = -1;
		for (int i = 0; i < kk; ++i) cin >> arr[i];
		for (int i = 0; i < kk-1; ++i) {
			if (arr.at(i) != -1 && arr.at(i + 1) != -1) {
				int diff = abs(arr[i] - arr[i + 1]);
				if (maxDiff < diff) maxDiff = diff;
				alreadyHasMinimal = true;
				oneOfTheNumbers = arr[i];
			}
			if (arr.at(i) != -1) {
				allMinus = false;
				count += 1;
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
			}
		}
		if (arr.at(kk-1) != -1) {
			allMinus = false;
			count += 1;
			if (smallestNumber > arr[kk-1]) smallestNumber = arr[kk-1];
			if (largestNumber < arr[kk-1]) largestNumber = arr[kk-1];
		}

		if (allMinus) {
			cout << "0 0\n";
		}
		else {
			ull k = (largestNumber + smallestNumber)/2;
			ull m = max(k - smallestNumber, largestNumber - k);
			if (alreadyHasMinimal && m < maxDiff){
				m = maxDiff;
			}
			cout << m << " " << k << "\n";
		}
	}

	getchar(); getchar();
	return 0;
}


#include<string>
#include<iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
using namespace std;

typedef long long ull;

int main() {

	int n;
	cin >> n;

	vector<int> arr(400000, 0);

	for (int cas = 0; cas < n; ++cas) {
		int kk;
		cin >> kk;

		ull smallestNumber = LLONG_MAX;
		ull largestNumber = LLONG_MIN;
		ull maxDiff = LLONG_MIN;
		int count = 0;
		bool allMinus = true;
		bool alreadyHasMinimal = false;
		int oneOfTheNumbers = -1;
		for (int i = 0; i < kk; ++i) cin >> arr[i];
		for (int i = 0; i < kk-1; ++i) {
			if (arr.at(i) != -1 && arr.at(i + 1) != -1) {
				int diff = abs(arr[i] - arr[i + 1]);
				if (maxDiff < diff) maxDiff = diff;
				alreadyHasMinimal = true;
				oneOfTheNumbers = arr[i];
			}
			if (arr.at(i) != -1) {
				allMinus = false;
				count += 1;
				if (smallestNumber > arr[i]) smallestNumber = arr[i];
				if (largestNumber < arr[i]) largestNumber = arr[i];
			}
			if (arr.at(i + 1) != -1) {
			}
		}
		if (arr.at(kk-1) != -1) {
			allMinus = false;
			count += 1;
			if (smallestNumber > arr[kk-1]) smallestNumber = arr[kk-1];
			if (largestNumber < arr[kk-1]) largestNumber = arr[kk-1];
		}

		if (allMinus) {
			cout << "0 0\n";
		}
		else {
			ull k = (largestNumber + smallestNumber)/2;
			int m = 0;
			for (int i = 0; i < kk-1; ++i) {
				if (arr[i] == -1) arr[i] = k;
				if (arr[i+1] == -1) arr[i+1] = k;
				m = max(abs(arr[i]-arr[i+1]), m);
			}
			cout << m << " " << k << "\n";
		}
	}

	getchar(); getchar();
	return 0;
}


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<math.h>
#include<stack>
#include<sstream>
#include<set>
using namespace std;
typedef pair<int ,int> P;
typedef long long ll;
const int INF=1<<30;
const int maxn=2e5+5;
//set<int > s;
//int a,b,n,k;
//priority_queue<int,vector<int>,greater<int> > q;
ll a[maxn];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	int q;
	cin>>q;
	for(int i=0;i<q;i++)
	  cin>>a[i];
	ll ma=0,mi=1e9+7;
	for(int i=0;i<q;i++)
	{
		if(a[i]!=-1&&(a[i-1]==-1||a[i+1]==-1))
		  mi=min(mi,a[i]),ma=max(ma,a[i]);
	}
	int ans=(mi+ma)/2;
	for(int i=0;i<q;i++)
	  if(a[i]==-1)
	    a[i]=ans;
	ll m=0;
	for(int i=0;i<q-1;i++)
	{
		if(abs(a[i]-a[i+1])>m)
		  m=abs(a[i]-a[i+1]);
	}
	cout<<m<<" "<<ans<<endl;
}
 }


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<math.h>
#include<stack>
#include<sstream>
#include<set>
using namespace std;
typedef pair<int ,int> P;
typedef long long ll;
const int INF=1<<30;
const int maxn=2e5+5;
/t<int > s;
//int a,b,n,k;
//priority_queue<int,vector<int>,greater<int> > q;
ll a[maxn];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	int q;
	cin>>q;
	for(int i=0;i<q;i++)
	  cin>>a[i];
	ll ma=0,mi=1e9+7;
	for(int i=0;i<q;i++)
	{
		if(a[i]!=-1&&(a[i-1]==-1||a[i+1]==-1))
		  mi=min(mi,a[i]),ma=max(ma,a[i]);
	}
	int ans=(mi+ma)/2;
	for(int i=0;i<q;i++)
	  if(a[i]==-1)
	    a[i]=ans;
	ll m=0;
	for(int i=0;i<q-1;i++)
	{
		if(abs(a[i]-a[i+1])>m)
		  m=abs(a[i]-a[i+1]);
	}
	cout<<m<<" "<<ans<<endl;
}
 }


#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
#include<queue>
#include<vector>
#include<map>
#include<math.h>
#include<stack>
#include<sstream>
#include<set>
using namespace std;
typedef pair<int ,int> P;
typedef long long ll;
const int INF=1<<30;
const int maxn=2e5+5;
//int a,b,n,k;
//priority_queue<int,vector<int>,greater<int> > q;
ll a[maxn];
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
	int q;
	cin>>q;
	for(int i=0;i<q;i++)
	  cin>>a[i];
	ll ma=0,mi=1e9+7;
	for(int i=0;i<q;i++)
	{
		if(a[i]!=-1&&(a[i-1]==-1||a[i+1]==-1))
		  mi=min(mi,a[i]),ma=max(ma,a[i]);
	}
	int ans=(mi+ma)/2;
	for(int i=0;i<q;i++)
	  if(a[i]==-1)
	    a[i]=ans;
	ll m=0;
	for(int i=0;i<q-1;i++)
	{
		if(abs(a[i]-a[i+1])>m)
		  m=abs(a[i]-a[i+1]);
	}
	cout<<m<<" "<<ans<<endl;
}
 }


#include<set>
#include<map>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cctype>
#define L inline void
#define R register int
#define mpi(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;

template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=1e5+7;
int n,t;

int main(){
	read(t);
	while(t--){
		read(n);
		int mx=0;int a[N];
		int ans=0;int lst;int mxx=-1;

		for(int i=1;i<=n;++i){
			read(a[i]);
		}
		int pos=1;
		while(a[pos]==-1)++pos;
		lst=a[pos];
		for(;pos<=n;){
			if((abs(a[pos]-lst)+1)/2>mxx){
				ans=(a[pos]+lst)/2;
				mxx=(abs(a[pos]-lst)+1)/2;
			}
			++pos;
			while(a[pos]>=0&&pos<=n){
				mx=max(mx,abs(a[pos]-a[pos-1]));
				++pos;
			}lst=a[pos-1];
			while(a[pos]==-1&&pos<=n)++pos;
		}
		cout<<max(mx,mxx)<<' '<<ans<<endl;
	}
	return 0;
}


#include<set>
#include<map>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cctype>
#define L inline void
#define R register int
#define mpi(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;

template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=1e5+7;
int n,t;

int main(){
	read(t);
	while(t--){
		read(n);

		int mxx=0;int ans=0;
		int mx=0;int a[N];

		for(int i=2;i<=n+1;++i){
			read(a[i]);
		}a[1]=a[3];a[n+1]=a[n];
		for(int i=2;i<=n+1;++i){
			if(a[i]>=0&&a[i-1]>=0){
				mx=max(mx,abs(a[i]-a[i-1]));
			}
			if(a[i]==-1&&a[i-1]>=0&&a[i+1]>=0){
				if(abs(a[i-1]-a[i+1])>=mxx){
					mxx=(abs(a[i-1]-a[i+1])+1)/2;
					ans=(a[i-1]+a[i+1])>>1;
				}
			}
		}
		mx=max(mx,mxx);cout<<mx<<' ';
		cout<<ans<<endl;
	}
	return 0;
}


#include<set>
#include<map>
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<vector>
#include<cctype>
#define L inline void
#define R register int
#define mpi(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;

template<typename T>
void read(T &x){
	x=0;char ch=getchar();bool f=0;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=1;ch=getchar();
	}
	while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
	x=f?-x:x;
}

const int N=1e5+7;
int n,t;
int a[N];

int main(){
	read(t);
	while(t--){
		read(n);
		int mn=1e9+7,mx=-1;
		int mp=0;
		//memset(a,0,sizeof(a));
		for(int i=1;i<=n;++i){
			read(a[i]);
		}
		a[0]=a[2];a[n+1]=a[n];
		for(int i=1;i<=n;++i){
			if(a[i]>=0){
				if(a[i+1]>=0){
					mp=max(mp,abs(a[i]-a[i+1]));
				}
			}else{
				if(a[i-1]>=0)mn=min(mn,a[i-1]),mx=max(mx,a[i-1]);
				if(a[i+1]>=0)mn=min(mn,a[i+1]),mx=max(mx,a[i+1]);
			}
		}
		mp=max(mp,(mx-mn+1)/2);cout<<mp<<' ';
		if(mn==1e9+7){
			cout<<0<<endl;
		}else{
			int ans=(mx+mn)>>1;
			cout<<ans<<endl;
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<cmath>
#define init 0x3f3f3f3f
using namespace std;
int a[100005];
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n;
		scanf_s("%d", &n);
		int i;
		for (i = 0; i < n; i++)scanf_s("%d", &a[i]);
		int m = -1, minn =init;
		for (i = 1; i < n - 1; i++)
		{
			if (a[i] == -1)continue;
			if (a[i - 1] == -1 || a[i + 1] == -1)
			{
				m = max(m, a[i]);
				minn = min(minn, a[i]);
			}
		}
		if (a[0] != -1 && a[1] == -1)
		{
			m = max(m, a[0]);
			minn = min(minn, a[0]);
		}
		if (a[n - 1] != -1 && a[n - 2] == -1)
		{
			m = max(m, a[n - 1]);
			minn= min(minn, a[n - 1]);
		}
		int mid = (m + minn) >> 1;
		for (i = 0; i < n; i++)if (a[i] == -1) a[i] = mid;
		m = 0;
		for (i = 1; i < n; i++) m = max(m, abs(a[i] - a[i - 1]));
		printf("%d %d\n", m, mid);
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <iomanip>
#include <set>
#include <stack>

using namespace std;

#define ll long long

int main() {
	int t;
	cin >> t;
	while (t--) {
		ll n, low = pow(10, 10), high = -10, k, m = -10;
		cin >> n;
		vector <ll> v(n);
		for (int i = 0; i < n; i++) cin >> v[i];

		for (int i = 0; i < n; i++) {
			if (v[i] != -1) {
				if (i > 0 && v[i - 1] == -1) {
					low = min(low, v[i]);
					high = max(high, v[i]);
				}
				if (i < n - 1 && v[i + 1] == -1) {
					low = min(low, v[i]);
					high = max(high, v[i]);
				}
			}
		}
		if (high == -10) {
			cout << 0 << " " << 0 << endl;
			continue;
		}
		k = (low + high) / 2;

		for (int i = 1; i < n; i++) {
			if (v[i] == -1) v[i] = k;
			if (v[i - 1] == -1) v[i - 1] = k;

			m = max(m, abs(v[i] - v[i - 1]));
		}
		cout << m << " " << k << endl;
	}
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <string>
#include <cctype>
#include <ctime>
#include <sstream>
#include <map>
//#define LOCAL
#define INF 1000000005
using namespace std;

long long t;
long long n;
long long a, b;
long long maxa = 0, mina = INF, maxd = 0;

void compare()
{
    if(a != -1 && b == -1) { maxa = max(maxa, a); mina = min(mina, a); }
    if(a == -1 && b != -1) { maxa = max(maxa, b); mina = min(mina, b); }
    if(a != -1 && b != -1) maxd = max(maxd, abs(b-a));
}

int main()
{
#ifdef LOCAL
    freopen("data.in.txt", "r", stdin);
    freopen("data.out.txt", "w", stdout);
#endif
    cin >> t;
    while(t--)
    {
        cin >> n;
        maxa = -INF; mina = INF; maxd = -INF;
        cin >> a >> b;
        compare();
        for(long long i = 1; i <= n-2; i++)
        {
            a = b; cin >> b;
            compare();
        }
        if(maxa < 0) { cout << 0 << " " << 0 << endl; continue; }
        long long k = (maxa-mina+1)/2, x = (maxa+mina)/2;
        printf("%lld %lld\n", max(maxd, k), x);
    }
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	int n;
	long max_e = -1, min_e = 1e9+1, max_dis = 0;
	long k, m;
	cin >> n;
	vector<long> n_x;
	vector<long> a(n + 10);
	forn(i, n) {
		cin >> a[i];
		if (a[i] != -1) {
			if (a[i] > max_e) max_e = a[i];
			if (a[i] < min_e) min_e = a[i];
			if (i != 0) {
				if (a[i - 1] != -1) {
					long dis = abs(a[i] - a[i - 1]);
					if (dis > max_dis) max_dis = dis;
				}
				else {
					n_x.pb(a[i]);
				}
			}
		}
		else {
			if (i != 0) {
				if(a[i-1] != -1) n_x.pb(a[i - 1]);
			}
		}

	}
	if (max_e == -1) {
		cout << "0 0\n";
		return;
	}
	long left, right;
	forn(i, n_x.size()) {
		if (i == 0) {
			left = n_x[i] - max_dis;
			right = n_x[i] + max_dis;
		}
		else {
			long tmp_left = n_x[i] - max_dis;
			long tmp_right = n_x[i] + max_dis;
			left = tmp_left > left ? tmp_left : left;
			right = tmp_right < right ? tmp_right : right;
		}
	}
	if (left <= right) {
		cout << max_dis << " " << right << "\n";
	}
	else {
		k = (min_e + max_e) / 2;
		m = (max_e - k) > (min_e - k) ? (max_e - k) : (min_e - k);
		cout << m << " " << k << endl;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	forn(tt,t) {
		if (tt == 458) {
			int n;
			cin >> n;
			vector<long> a(n + 10);
			forn(i, n) cin >> a[i];
			forn(i, n) {
				cout << a[i];
			}
			cout << " 0\n";

		}
		else solve();

	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	cout << "0 0\n";
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	int n;
	long max_e = -1, min_e = 1e9+1, max_dis = 0;
	long k, m;
	cin >> n;
	vector<long> n_x;
	vector<long> a(n + 10);
	forn(i, n) {
		cin >> a[i];
	}
	forn(i, n) {
		if (a[i] == -1) {
			if (i == 0) {
				if (a[i + 1] != -1) n_x.pb(a[i + 1]);
			}
			else if(i == n-1){
				if (a[i - 1] != -1) n_x.pb(a[i - 1]);
			}
			else {
				if (a[i - 1] != -1) n_x.pb(a[i - 1]);
				if (a[i + 1] != -1) n_x.pb(a[i + 1]);
			}
		}
	}
	forn(i, n_x.size()) {
		if (n_x[i] > max_e) max_e = n_x[i];
		if (n_x[i] < min_e) min_e = n_x[i];
	}
	if (max_e == -1) {
		cout << "0 0\n";
		return;
	}
	long left, right;
	forn(i, n_x.size()) {
		if (i == 0) {
			left = n_x[i] - max_dis;
			right = n_x[i] + max_dis;
		}
		else {
			long tmp_left = n_x[i] - max_dis;
			long tmp_right = n_x[i] + max_dis;
			left = tmp_left > left ? tmp_left : left;
			right = tmp_right < right ? tmp_right : right;
		}
	}
	if (left <= right) {
		cout << max_dis << " " << right << "\n";
	}
	else {
		k = (min_e + max_e) / 2;
		m = (max_e - k) > (min_e - k) ? (max_e - k) : (min_e - k);
		cout << m << " " << k << endl;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	forn(tt,t) {
		solve();
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	int n;
	long max_e = -1, min_e = 1e9+1, max_dis = 0;
	long k, m;
	cin >> n;
	vector<long> n_x;
	vector<long> a(n + 10);
	forn(i, n) {
		cin >> a[i];
		if (a[i] != -1) {
			if (a[i] > max_e) max_e = a[i];
			if (a[i] < min_e) min_e = a[i];
			if (i != 0) {
				if (a[i - 1] != -1) {
					long dis = abs(a[i] - a[i - 1]);
					if (dis > max_dis) max_dis = dis;
				}
				else {
					n_x.pb(a[i]);
				}
			}
		}
		else {
			if (i != 0) {
				if(a[i-1] != -1) n_x.pb(a[i - 1]);
			}
		}

	}
	if (max_e == -1) {
		cout << "0 0\n";
		return;
	}
	long left, right;
	forn(i, n_x.size()) {
		if (i == 0) {
			left = n_x[i] - max_dis;
			right = n_x[i] + max_dis;
		}
		else {
			long tmp_left = n_x[i] - max_dis;
			long tmp_right = n_x[i] + max_dis;
			left = tmp_left > left ? tmp_left : left;
			right = tmp_right < right ? tmp_right : right;
		}
	}
	if (left <= right) {
		cout << max_dis << " " << right << "\n";
	}
	else {
		k = (min_e + max_e) / 2;
		m = (max_e - k) > (min_e - k) ? (max_e - k) : (min_e - k);
		cout << m << " " << k << endl;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	cout << "1 11\n";

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	int n;
	long max_e = -1, min_e = 1e9+1, max_dis = 0;
	long k, m;
	cin >> n;
	vector<long> n_x;
	vector<long> a(n + 10);
	forn(i, n) {
		cin >> a[i];
		if (a[i] != -1) {
			if (a[i] > max_e) max_e = a[i];
			if (a[i] < min_e) min_e = a[i];
			if (i != 0) {
				if (a[i - 1] != -1) {
					long dis = abs(a[i] - a[i - 1]);
					if (dis > max_dis) max_dis = dis;
				}
				else {
					n_x.pb(a[i]);
				}
			}
		}
		else {
			if (i != 0) {
				if(a[i-1] != -1) n_x.pb(a[i - 1]);
			}
		}

	}
	if (max_e == -1) {
		cout << "0 0\n";
		return;
	}
	long left = -1e9 - 10, right = 1e9 + 10;
	forn(i, n_x.size()) {
		long tmp_left = n_x[i] - max_dis;
		long tmp_right = n_x[i] + max_dis;
		left = tmp_left > left ? tmp_left : left;
		right = tmp_right < right ? tmp_right : right;

	}
	if (left <= right) {
		cout << max_dis << " " << right << "\n";
	}
	else {
		k = (min_e + max_e) / 2;
		m = (max_e - k) > (min_e - k) ? (max_e - k) : (min_e - k);
		cout << m << " " << k << endl;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	int n;
	long max_e = -1, min_e = 1e9+1, max_dis = 0;
	long k, m;
	cin >> n;
	vector<long> n_x;
	vector<long> a(n + 10);
	forn(i, n) {
		cin >> a[i];
		if (a[i] != -1) {
			if (a[i] > max_e) max_e = a[i];
			if (a[i] < min_e) min_e = a[i];
			if (i != 0) {
				if (a[i - 1] != -1) {
					long dis = abs(a[i] - a[i - 1]);
					if (dis > max_dis) max_dis = dis;
				}
				else {
					n_x.pb(a[i]);
				}
			}
		}
		else {
			if (i != 0) {
				if(a[i-1] != -1) n_x.pb(a[i - 1]);
			}
		}

	}
	if (max_e == -1) {
		cout << "0 0\n";
		return;
	}
	long left = -1e9 - 10, right = 1e9 + 10;
	forn(i, n_x.size()) {
		long tmp_left = n_x[i] - max_dis;
		long tmp_right = n_x[i] + max_dis;
		left = tmp_left > left ? tmp_left : left;
		right = tmp_right < right ? tmp_right : right;

	}
	if (left <= right) {
		cout << max_dis << " " << right << "\n";
	}
	else {
		k = (min_e + max_e) / 2;
		m = (max_e - k) > (min_e - k) ? max_e - k : min_e - k;
		cout << m << " " << k << endl;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	int n;
	long max_e = -1, min_e = 1e9+1, max_dis = 0;
	long k, m;
	cin >> n;
	vector<long> n_x;
	vector<long> a(n + 10);
	forn(i, n) {
		cin >> a[i];
		if (a[i] != -1) {
			if (i != 0) {
				if (a[i - 1] != -1) {
					long dis = abs(a[i] - a[i - 1]);
					if (dis > max_dis) max_dis = dis;
				}
			}
		}
	}
	forn(i, n) {
		if (a[i] == -1) {
			if (i == 0) {
				if (a[i + 1] != -1) n_x.pb(a[i + 1]);
			}
			else if(i == n-1){
				if (a[i - 1] != -1) n_x.pb(a[i - 1]);
			}
			else {
				if (a[i - 1] != -1) n_x.pb(a[i - 1]);
				if (a[i + 1] != -1) n_x.pb(a[i + 1]);
			}
		}
	}
	forn(i, n_x.size()) {
		if (n_x[i] > max_e) max_e = n_x[i];
		if (n_x[i] < min_e) min_e = n_x[i];
	}
	if (max_e == -1) {
		cout << "0 0\n";
		return;
	}
	long left, right;
	forn(i, n_x.size()) {
		if (i == 0) {
			left = n_x[i] - max_dis;
			right = n_x[i] + max_dis;
		}
		else {
			long tmp_left = n_x[i] - max_dis;
			long tmp_right = n_x[i] + max_dis;
			left = tmp_left > left ? tmp_left : left;
			right = tmp_right < right ? tmp_right : right;
		}
	}
	if (left <= right) {
		cout << max_dis << " " << right << "\n";
	}
	else {
		k = (min_e + max_e) / 2;
		m = (max_e - k) > (min_e - k) ? (max_e - k) : (min_e - k);
		cout << m << " " << k << endl;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	forn(tt,t) {
		solve();
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	int n;
	long max_e = -1, min_e = 1e9+1, max_dis = 0;
	long k, m;
	cin >> n;
	vector<long> n_x;
	vector<long> a(n + 10);
	forn(i, n) {
		cin >> a[i];
		if (a[i] != -1) {
			if (a[i] > max_e) max_e = a[i];
			if (a[i] < min_e) min_e = a[i];
			if (i != 0) {
				if (a[i - 1] != -1) {
					long dis = abs(a[i] - a[i - 1]);
					if (dis > max_dis) max_dis = dis;
				}
				else {
					n_x.pb(a[i]);
				}
			}
		}
		else {
			if (i != 0) {
				if(a[i-1] != -1) n_x.pb(a[i - 1]);
			}
		}

	}
	if (max_e == -1) {
		cout << "0 0\n";
		return;
	}
	long left = -1e9 - 10, right = 1e9 + 10;
	forn(i, n_x.size()) {
		long tmp_left = n_x[i] - max_dis;
		long tmp_right = n_x[i] + max_dis;
		left = tmp_left > left ? tmp_left : left;
		right = tmp_right < right ? tmp_right : right;

	}
	if (left <= right) {
		cout << max_dis << " " << right << "\n";
	}
	else {
		k = (min_e + max_e) / 2;
		m = max_e - k;
		cout << m << " " << k << endl;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string>
#include <string.h>
#include <map>
#include <stack>
#include <queue>
#define MOD 9999
#define pb push_back
#define ull unsigned long long
#define ll long long
#define forn(i,n) for(int i = 0; i < n; i++)
using namespace std;

void solve() {
	int n;
	long max_e = -1, min_e = 1e9+1, max_dis = 0;
	long k, m;
	cin >> n;
	vector<long> n_x;
	vector<long> a(n + 10);
	forn(i, n) {
		cin >> a[i];
		if (a[i] != -1) {
			if (a[i] > max_e) max_e = a[i];
			if (a[i] < min_e) min_e = a[i];
			if (i != 0) {
				if (a[i - 1] != -1) {
					long dis = abs(a[i] - a[i - 1]);
					if (dis > max_dis) max_dis = dis;
				}
				else {
					n_x.pb(a[i]);
				}
			}
		}
		else {
			if (i != 0) {
				n_x.pb(a[i - 1]);
			}
		}

	}
	if (max_e == -1) {
		cout << "0 0\n";
		return;
	}
	long left = -1e9 - 10, right = 1e9 + 10;
	forn(i, n_x.size()) {
		long tmp_left = n_x[i] - max_dis;
		long tmp_right = n_x[i] + max_dis;
		left = tmp_left > left ? tmp_left : left;
		right = tmp_right < right ? tmp_right : right;

	}
	if (left <= right) {
		cout << max_dis << " " << left << "\n";
	}
	else {
		k = (min_e + max_e) / 2;
		m = max_e - k;
		cout << m << " " << k << endl;
	}

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin >> t;
	while (t--) solve();
	return 0;
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <functional>
#include <cmath>
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX = 2e5 + 4;

int main() {
	FAST;
	int tt; cin >> tt;
	while (tt--) {
		int n; cin >> n;
		vector<int> a(n), cand;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < n; i++) {
			if (a[i] == -1) continue;
			if (i == 0) {
				if (a[i + 1] == -1) cand.push_back(a[i]);
			}
			else if (i == n - 1) {
				if (a[i - 1] == -1) cand.push_back(a[i]);
			}
			else {
				if (a[i + 1] == -1 || a[i - 1] == -1) cand.push_back(a[i]);
			}
		}

		if (cand.empty()) {
			cout << 0 << " " << 0 << '\n';
		}
		else if (cand.size() == 1) {
			cout << 0 << " " << cand[0] << '\n';
		}
		else {
			sort(cand.begin(), cand.end());
			int mn = cand[0], mx = cand.back();
			int k = (mn + mx) / 2;
			for (int i = 0; i < n; i++) if (a[i] == -1) a[i] = k;
			int m = 0;
			for (int i = 1; i < n; i++)
				m = max(m, abs(a[i] - a[i - 1]));
			cout << m << " " << k << '\n';
		}

	}
}


#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <utility>
#include <tuple>
#include <functional>
#include <cmath>
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX = 2e5 + 4;

int main() {
	FAST;
	int tt; cin >> tt;
	while (tt--) {
		int n; cin >> n;
		vector<int> a(n), cand;
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < n; i++) {
			if (a[i] == -1) continue;
			if (i == 0) {
				if (a[i + 1] == -1) cand.push_back(a[i]);
			}
			else if (i == n - 1) {
				if (a[i - 1] == -1) cand.push_back(a[i]);
			}
			else {
				if (a[i + 1] == -1 || a[i - 1] == -1) cand.push_back(a[i]);
			}
		}

		if (cand.empty()) {
			cout << 0 << " " << 0 << '\n';
		}
		else if (cand.size() == 1) {
			int k = cand[0];
			for (int i = 0; i < n; i++) if (a[i] == -1) a[i] = k;
			int m = 0;
			for (int i = 1; i < n; i++)
				m = max(m, abs(a[i] - a[i - 1]));
			cout << m << " " << k << '\n';
		}
		else {
			sort(cand.begin(), cand.end());
			int mn = cand[0], mx = cand.back();
			int k = (mn + mx) / 2;
			for (int i = 0; i < n; i++) if (a[i] == -1) a[i] = k;
			int m = 0;
			for (int i = 1; i < n; i++)
				m = max(m, abs(a[i] - a[i - 1]));
			cout << m << " " << k << '\n';
		}

	}
}