#include <bits/stdc++.h>
using namespace std;
void Suhaib_Sawalha() {
  long long n;
  cin >> n;
  long long abso(INT_MIN), Max(INT_MIN), Min(INT_MAX);
  long long arr[n];
  for (long long i = 0; i < n; ++i) cin >> arr[i];
  if (arr[0] == -1 && arr[1] != -1) Max = Min = arr[1];
  for (long long i = 1; i < n; ++i) {
    if (arr[i] != -1 && arr[i - 1] != -1)
      abso = max(abso, abs(arr[i] - arr[i - 1]));
    else if (arr[i] == -1) {
      if (arr[i - 1] != -1)
        Max = max(Max, arr[i - 1]), Min = min(Min, arr[i - 1]);
      if (i != n - 1 && arr[i + 1] != -1)
        Max = max(Max, arr[i + 1]), Min = min(Min, arr[i + 1]);
    }
  }
  if (Min == INT_MAX) {
    printf("0 1\n");
    return;
  }
  long long j = (Max + Min) / 2;
  printf("%lld %lld\n", max(abso, max(Max - j, j - Min)), j);
}
void Suhaib_Sawalha1() {
  long long t;
  cin >> t;
  while (t--) {
    Suhaib_Sawalha();
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Suhaib_Sawalha1();
  return 0;
}
