#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
void tcase(int Tcase) {
  int n, mn = 1e9 + 6, mx = -2;
  scanf("%d", &n);
  int a[n + 5];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == -1) {
      if (i > 0) {
        if (a[i - 1] != -1) {
          mn = min(mn, a[i - 1]);
          mx = max(mx, a[i - 1]);
        }
      }
      if (i < n - 1) {
        if (a[i + 1] != -1) {
          mn = min(mn, a[i + 1]);
          mx = max(mx, a[i + 1]);
        }
      }
    }
  }
  int k = -1, m = -1;
  if (mx == -2) {
    k = 0;
    for (int i = 0; i < n; i++)
      if (a[i] == -1) a[i] = 0;
    for (int i = 0; i < n - 1; i++) m = max(m, abs(a[i] - a[i + 1]));
  } else {
    k = (mn + mx) / 2;
    for (int i = 0; i < n; i++) {
      if (a[i] == -1) a[i] = k;
    }
    for (int i = 0; i < n - 1; i++) {
      m = max(m, abs(a[i] - a[i + 1]));
    }
  }
  printf("%d %d\n", m, k);
}
int main() {
  int T = 1;
  scanf("%d", &T);
  for (int Tcase = 1; Tcase <= T; Tcase++) {
    tcase(Tcase);
  }
}
