#include <bits/stdc++.h>
using namespace std;
void deepu() {}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  deepu();
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int a[n];
    long long int ma = LLONG_MIN, mi = LLONG_MAX;
    for (int i = 0; i < n; i++) cin >> a[i];
    if (n >= 2 && a[0] == -1) {
      if (a[1] != -1) {
        ma = max(ma, a[1]);
        mi = min(mi, a[1]);
      }
    }
    for (int i = 1; i < n - 1; i++) {
      if (a[i] == -1) {
        if (a[i + 1] != -1) {
          ma = max(ma, a[i + 1]);
          mi = min(mi, a[i + 1]);
        }
        if (a[i - 1] != -1) {
          mi = min(mi, a[i - 1]);
          ma = max(ma, a[i - 1]);
        }
      }
    }
    if (n >= 2 && a[n - 1] == -1) {
      if (a[n - 2] != -1) {
        ma = max(ma, a[n - 2]);
        mi = min(mi, a[n - 2]);
      }
    }
    if (ma == LLONG_MIN && mi == LLONG_MAX) ma = 0, mi = 0;
    ma = max(0ll, ma);
    mi = max(0ll, mi);
    long long int k = (ma + mi + 1) / 2;
    long long int m = LLONG_MIN;
    if (a[0] == -1) a[0] = k;
    for (int i = 1; i < n; i++) {
      if (a[i] == -1) {
        a[i] = k;
      }
      m = max(m, abs(a[i] - a[i - 1]));
    }
    cout << m << " " << k << "\n";
  }
  return 0;
}
