#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long a[N], k, n;
bool ch(long long m) {
  long long l = -2e9, r = 2e9;
  for (int i = 1; i <= n; i++) {
    if (i != 1 && a[i] != -1 && a[i - 1] != -1) {
      if (abs(a[i - 1] - a[i]) > m) return 0;
    }
    if (i != n && a[i] != -1 && a[i + 1] != -1) {
      if (abs(a[i + 1] - a[i]) > m) return 0;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] == -1) {
      if (i != 1 && a[i - 1] != -1) {
        l = max(l, a[i - 1] - m);
        r = min(r, a[i - 1] + m);
      }
      if (i != n && a[i + 1] != -1) {
        l = max(l, a[i + 1] - m);
        r = min(r, a[i + 1] + m);
      }
    }
  }
  if (l <= r) {
    k = l;
    return 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    long long lo = 0, hi = 2e9, mid;
    while (lo < hi) {
      mid = lo + (hi - lo) / 2;
      if (ch(mid))
        hi = mid;
      else
        lo = mid + 1;
    }
    cout << lo << ' ' << max(0LL, k) << "\n";
  }
  return 0;
}
