#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 3e5 + 15, INF = 2e9;
int n, a[N];
void solve() {
  cin >> n;
  int mn = INF, mx = -INF;
  for (int i = 0, ggdem = n; i < ggdem; i++) cin >> a[i];
  for (int i = 0, ggdem = n; i < ggdem; i++) {
    if (a[i] == -1) {
      if (i - 1 >= 0 && a[i - 1] != -1) {
        mn = min(mn, a[i - 1]);
        mx = max(mx, a[i - 1]);
      }
      if (i + 1 < n && a[i + 1] != -1) {
        mn = min(mn, a[i + 1]);
        mx = max(mx, a[i + 1]);
      }
    }
  }
  int avg = (mn + mx) / 2;
  for (int i = 0, ggdem = n; i < ggdem; i++)
    if (a[i] < 0) a[i] = avg;
  int res = 0;
  for (int i = 1, ggdem = n; i < ggdem; i++)
    res = max(res, abs(a[i] - a[i - 1]));
  cout << res << " " << avg << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) solve();
}
