#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
void solve() {
  int n;
  cin >> n;
  vi a(n);
  for (ll i = 0; i < (n); i++) {
    cin >> a[i];
  }
  int mn = INT_MAX, mx = INT_MIN;
  for (int i = 0; i < n; i++) {
    if (i > 0 && a[i] == -1 && a[i - 1] != -1) {
      mx = max(mx, a[i - 1]);
      mn = min(mn, a[i - 1]);
    }
    if (i < n - 1 && a[i] == -1 && a[i + 1] != -1) {
      mx = max(mx, a[i + 1]);
      mn = min(mn, a[i + 1]);
    }
  }
  int k = (mx + mn) / 2;
  int m = INT_MIN;
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) a[i] = k;
    if (i != 0) m = max(m, abs(a[i] - a[i - 1]));
  }
  cout << m << " " << k << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  ll t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
}
