#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, t, m;
  cin >> t;
  while (t--) {
    cin >> n;
    int a[n + 5], mx = 0, mn = 1000000000, d = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
      if (i > 0 && a[i] == -1 && a[i - 1] != -1)
        mn = min(a[i - 1], mn), mx = max(a[i - 1], mx);
      if (i < n - 1 && a[i] == -1 && a[i + 1] != -1)
        mn = min(a[i + 1], mn), mx = max(a[i + 1], mx);
    }
    mn += (mx - mn) / 2;
    if (a[0] == -1) a[0] = mn;
    for (int i = 1; i < n; i++) {
      if (a[i] == -1) a[i] = mn;
      d = max(abs(a[i] - a[i - 1]), d);
    }
    cout << d << ' ' << mn << endl;
  }
}
