#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
const long long MX = 1e15;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
int t, n, arr[N], m = INT32_MAX, kk;
int findm(int k) {
  int mm = -INT32_MAX;
  for (int i = 1; i < n; i++) {
    int x = arr[i - 1], y = arr[i];
    if (x == -1) x = k;
    if (y == -1) y = k;
    mm = max(mm, abs(x - y));
  }
  return mm;
}
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    int st = 0, nd = 1e9, m1, m2;
    while (st <= nd) {
      m1 = st + (nd - st) / 3;
      m2 = nd - (nd - st) / 3;
      int mm1 = findm(m1), mm2 = findm(m2);
      if (m1 == m2) {
        cout << mm1 << " " << m1 << '\n';
        break;
      }
      if (mm1 < mm2) {
        nd = m2 - 1;
      } else {
        st = m1 + 1;
      }
    }
  }
  return 0;
}
