#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = -1e-2;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const long long mod = 1e9 + 7;
const int MX = INT_MAX;
const int N = 1e6 + 5;
void Open() {}
int n;
vector<int> v;
int gl = 0, gr = 0;
pair<int, int> check(int m) {
  int dif = 0;
  vector<int> vv = v;
  for (int i = 0; i < n - 1; i++) {
    if (v[i] == -1 && v[i + 1] == -1) continue;
    if (v[i] == -1) {
      if (dif < abs(m - v[i + 1])) {
        dif = abs(m - v[i + 1]);
        if (m > v[i + 1]) {
          gr = 5;
          gl = 0;
        } else {
          gl = 5;
          gr = 0;
        }
      }
    } else if (v[i + 1] == -1) {
      if (dif < abs(v[i] - m)) {
        dif = abs(v[i] - m);
        if (m > v[i]) {
          gr = 5;
          gl = 0;
        } else {
          gl = 5;
          gr = 0;
        }
      }
    } else {
      if (dif < abs(v[i] - v[i + 1])) {
        gl = 0, gr = 0;
        dif = abs(v[i] - v[i + 1]);
      }
    }
  }
  if (gr == 5) {
    return {dif, 3};
  } else if (gl == 5) {
    return {dif, 1};
  }
  return {dif, 2};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Open();
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    v = vector<int>(n);
    for (int i = 0; i < n; i++) {
      cin >> v[i];
    }
    int l = 0, r = 1e9, md, k = 0, m = 1e9;
    while (l <= r) {
      md = (l + r) / 2;
      pair<int, int> dif = check(md);
      if (dif.second == 3) {
        if (dif.first < m) {
          m = dif.first;
          k = md;
        }
        r = md - 1;
      } else {
        if (dif.first < m) {
          m = dif.first;
          k = md;
        }
        l = md + 1;
      }
    }
    cout << m << " " << k << "\n";
  }
}
