#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 7;
const long long mod = 1e9 + 7;
int a[maxn];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    int min = 1e9 + 1;
    int maxx = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
      if (a[i] == -1) {
        if (i > 1) {
          if (a[i - 1] != -1) {
            if (a[i - 1] > maxx) maxx = a[i - 1];
            if (a[i - 1] < min) min = a[i - 1];
          }
        }
        if (i < n) {
          if (a[i + 1] != -1) {
            if (a[i + 1] > maxx) maxx = a[i + 1];
            if (a[i + 1] < min) min = a[i + 1];
          }
        }
      }
    }
    if (min == 1e9 + 1) {
      min = 0;
      maxx = 0;
    }
    int ss = maxx + min;
    ss /= 2;
    int max_abs;
    if (maxx - ss > min - ss)
      max_abs = maxx - ss;
    else
      max_abs = min - ss;
    if (a[1] == -1) a[1] = ss;
    for (int i = 2; i <= n; i++) {
      if (a[i] == -1) a[i] = ss;
      if (abs(a[i] - a[i - 1]) > max_abs) max_abs = abs(a[i] - a[i - 1]);
    }
    cout << max_abs << " " << ss << endl;
  }
}
