#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105000;
int n;
int a[MAXN];
vector<int> v;
int mn, mx, curDiff;
int getDiff(int x) { return max(abs(x - mn), abs(x - mx)); }
int get(int x) {
  for (int i = 0; i < (int)v.size(); i++) {
    int cur = v[i];
    if (getDiff(cur + x) == x) {
      return cur + x;
    }
    if (cur - x >= 0 && getDiff(cur - x) == x) {
      return cur - x;
    }
  }
  return -1;
}
void solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  v.clear();
  curDiff = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) {
      if (i > 0 && a[i - 1] != -1) {
        v.push_back(a[i - 1]);
      }
      if (i + 1 < n && a[i + 1] != -1) {
        v.push_back((a[i + 1]));
      }
    } else {
      if (i > 0 && a[i - 1] != -1) {
        curDiff = max(curDiff, abs(a[i] - a[i - 1]));
      }
    }
  }
  if ((int)v.size() == 0) {
    printf("%d %d\n", 0, 0);
    return;
  }
  sort(v.begin(), v.end());
  mn = v[0], mx = v.back();
  int l = curDiff, r = 1e9;
  while (l < r) {
    int mid = (l + r) / 2;
    if (get(mid) != -1) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  printf("%d %d\n", l, get(l));
}
int main() {
  int tn;
  cin >> tn;
  while (tn--) {
    solve();
  }
  return 0;
}
