#include <bits/stdc++.h>
using namespace std;
int main() {
  {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  }
  long long int t, n, mx, mn, dif, r, i, adj, adr;
  cin >> t;
  while (t--) {
    cin >> n;
    long long int a[n];
    mx = -1000000010;
    mn = 1000000010;
    dif = 0;
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (i = 0; i < n; i++) {
      if (i > 0 && a[i] == -1 && a[i - 1] >= 0) {
        mn = min(mn, a[i - 1]);
        mx = max(mx, a[i - 1]);
      }
      if (i < n - 1 && a[i] == -1 && a[i + 1] >= 0) {
        mn = min(mn, a[i + 1]);
        mx = max(mx, a[i + 1]);
      }
    }
    r = (mn + mx) / 2;
    for (int i = 0; i < n; i++) {
      if (a[i] == -1) {
        a[i] = r;
      }
      if (i) dif = max(dif, abs(a[i] - a[i - 1]));
    }
    cout << dif << " " << r << endl;
  }
  return 0;
}
