#include <bits/stdc++.h>
using namespace std;
int n, a[100005];
int main() {
  int _;
  scanf("%d", &_);
  while (_--) {
    int mx = 0, mm = 1e9 + 5, cnt = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", a + i);
    for (int i = 0; i < n; i++) {
      if (a[i] == -1) continue;
      if (i && a[i - 1] == -1) mx = max(mx, a[i]), mm = min(mm, a[i]), cnt++;
      if (i + 1 < n && a[i + 1] == -1)
        mx = max(mx, a[i]), mm = min(mm, a[i]), cnt++;
    }
    int k;
    if (cnt)
      k = (mx + mm) / 2;
    else
      k = 0;
    for (int i = 0; i < n; i++)
      if (a[i] == -1) a[i] = k;
    int ans = 0;
    for (int i = 1; i < n; i++) ans = max(abs(a[i] - a[i - 1]), ans);
    printf("%d %d\n", ans, k);
  }
  return 0;
}
