#include <bits/stdc++.h>
using namespace std;
#define oo 1000000010
#define mod 1000000007
const int N = 300010;
int n , arr[N] ;
void solve(){
int mn = oo , mx = -oo;
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&arr[i]);
}
for(int i = 0;i<n;i++){
if(i > 0 && arr[i] == -1 && arr[i - 1] != -1)
mn = min(mn , arr[i - 1]) , mx = max(mx , arr[i - 1]);
if(i < n - 1 && arr[i] == - 1 && arr[i + 1] != -1)
mn = min(mn , arr[i + 1]) , mx = max(mx , arr[i + 1]);
}
int res = (mx + mn) / 2;
int ans = 0;
for(int i=0;i<n;i++){
if(arr[i] == -1)
arr[i] = res;
if(i)
ans = max(ans,abs(arr[i] - arr[i - 1]));
}
printf("%d %d\n",ans,res);
}
int main(){
int t;
cin >> t;
while(t--){
solve();
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgb28gMTAwMDAwMDAxMAojZGVmaW5lIG1vZCAxMDAwMDAwMDA3CmNvbnN0IGludCBOID0gMzAwMDEwOwppbnQgbiAsIGFycltOXSA7IAoKdm9pZCBzb2x2ZSgpewogICAgaW50IG1uID0gb28gLCBteCA9IC1vbzsKCXNjYW5mKCIlZCIsJm4pOwoJZm9yKGludCBpPTA7aTxuO2krKyl7CgkJc2NhbmYoIiVkIiwmYXJyW2ldKTsKCX0KCWZvcihpbnQgaSA9IDA7aTxuO2krKyl7CgkJaWYoaSA+IDAgJiYgYXJyW2ldID09IC0xICYmIGFycltpIC0gMV0gIT0gLTEpCgkJCW1uID0gbWluKG1uICwgYXJyW2kgLSAxXSkgLCBteCA9IG1heChteCAsIGFycltpIC0gMV0pOwoJCWlmKGkgPCBuIC0gMSAmJiBhcnJbaV0gPT0gLSAxICYmIGFycltpICsgMV0gIT0gLTEpCgkJCW1uID0gbWluKG1uICwgYXJyW2kgKyAxXSkgLCBteCA9IG1heChteCAsIGFycltpICsgMV0pOwoJfQoJaW50IHJlcyA9IChteCArIG1uKSAvIDI7CglpbnQgYW5zID0gMDsKCWZvcihpbnQgaT0wO2k8bjtpKyspewoJCWlmKGFycltpXSA9PSAtMSkKCQkJYXJyW2ldID0gcmVzOwoJCWlmKGkpCgkJCWFucyA9IG1heChhbnMsYWJzKGFycltpXSAtIGFycltpIC0gMV0pKTsKCX0KCXByaW50ZigiJWQgJWRcbiIsYW5zLHJlcyk7Cn0KCgppbnQgbWFpbigpewoJaW50IHQ7CgljaW4gPj4gdDsKCXdoaWxlKHQtLSl7CgkgICAgc29sdmUoKTsKCX0KCXJldHVybiAwOwp9