#include <bits/stdc++.h>
using namespace std;
map<long long, long long> prime;
long long powerFunction(long long x, long long y) {
  long long res = 1;
  long long p = 1000000007;
  ;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
void sieve(long long n) {
  for (int p = 2; p * p <= n; p++) {
    if (prime[p]) {
      for (int i = p * p; i <= n; i += p) prime[i] = 0;
    }
  }
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<long long> v;
    long long vis[n];
    for (int i = 0; i < n; i++) vis[i] = 0;
    if (a[0] == -1) {
      if (a[1] != -1) {
        v.push_back(a[1]);
        vis[1] = 1;
      }
    }
    for (int i = 1; i < n - 1; i++) {
      if (a[i] == -1) {
        if (a[i - 1] != -1 && vis[i - 1] == 0) {
          v.push_back(a[i - 1]);
          vis[i - 1] = 1;
        }
        if (a[i + 1] != -1 && vis[i + 1] == 0) {
          v.push_back(a[i + 1]);
          vis[i + 1] = 1;
        }
      }
    }
    if (a[n - 1] == -1) {
      if (a[n - 2] != -1 && vis[n - 2] == 0) {
        v.push_back(a[n - 2]);
        vis[n - 2] = 1;
      }
    }
    long long sum = 0, k = 0, mxm = INT_MIN, mnm = INT_MAX;
    for (int i = 0; i < v.size(); i++) {
      sum += v[i];
      mxm = max(mxm, v[i]);
      mnm = min(mnm, v[i]);
    }
    if (v.size() == 0) {
      cout << 0 << " " << 1 << '\n';
      continue;
    }
    k = (mnm + mxm) / 2;
    for (int i = 0; i < n; i++) {
      if (a[i] == -1) a[i] = k;
    }
    long long m = INT_MIN;
    for (int i = 1; i < n; i++) {
      m = max(m, abs(a[i] - a[i - 1]));
    }
    cout << m << " " << k << '\n';
  }
}
