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