#include <bits/stdc++.h>
using namespace std;
long long a[400005];
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long minv = 999999999999, maxv = -999990999999;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      if (i > 0 && a[i - 1] == -1 && a[i] != -1) {
        maxv = max(a[i], maxv);
        minv = min(a[i], minv);
      }
      if (i > 0 && a[i - 1] != -1 && a[i] == -1) {
        maxv = max(a[i - 1], maxv);
        minv = min(a[i - 1], minv);
      }
    }
    long long ans = -99999999999;
    for (int i = 0; i < n - 1; i++) {
      if (a[i] == -1) a[i] = (maxv + minv + 1) / 2;
      if (a[i + 1] == -1) a[i + 1] = (maxv + minv + 1) / 2;
      long long tmp = abs(a[i] - a[i + 1]);
      ans = max(ans, tmp);
    }
    cout << ans << " " << (maxv + minv + 1) / 2 << endl;
  }
}
