#include <bits/stdc++.h>
using namespace std;
const long long q = 239017;
const long long mod = 1e9 + 7;
const long long mod2 = 1e9 + 13;
const long long MAXN = 1e5 + 100;
const long long MAXM = 700;
const long long L = 26;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void $main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v(n);
    for (long long i = 0; i < n; ++i) cin >> v[i];
    long long mn = (long long)1e18, mx = -(long long)1e18;
    for (long long i = 0; i < n; ++i) {
      if (v[i] != -1) continue;
      if (i > 0 && v[i - 1] != -1) {
        mn = min(mn, v[i - 1]);
        mx = max(mx, v[i - 1]);
      }
      if (i < n - 1 && v[i + 1] != -1) {
        mn = min(mn, v[i + 1]);
        mx = max(mx, v[i + 1]);
      }
    }
    if (mn == (long long)1e18) {
      cout << 0 << " " << 0 << '\n';
      continue;
    }
    long long k = (mn + mx) / 2;
    long long meg = -(long long)1e18;
    for (long long i = 1; i < n; ++i) {
      long long f = v[i - 1];
      if (f < 0) f = k;
      long long s = v[i];
      if (s < 0) s = k;
      meg = max(meg, abs(f - s));
    }
    cout << meg << " " << k << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  $main();
  return 0;
}
