#include <bits/stdc++.h>
using namespace std;
long long int check(vector<long long int> arr, long long int n,
                    long long int k) {
  long long int ans = INT_MIN, i;
  for (i = 0; i < n; i++) {
    if (arr[i] == -1) arr[i] = k;
  }
  for (i = 0; i < n - 1; i++) ans = max(ans, abs(arr[i] - arr[i + 1]));
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    long long int n, i, high = INT_MIN, low = INT_MAX;
    cin >> n;
    long long int ans, x;
    vector<long long int> arr;
    for (i = 0; i < n; i++) {
      cin >> x;
      arr.push_back(x);
      if (arr[i] != -1) {
        low = min(low, arr[i]);
        high = max(high, arr[i]);
      }
    }
    if (low == INT_MAX && high == INT_MIN) {
      cout << "0 0" << endl;
      continue;
    }
    while (low <= high) {
      long long int mid = low + (high - low) / 2;
      if (check(arr, n, mid - 1) >= check(arr, n, mid) &&
          check(arr, n, mid) <= check(arr, n, mid + 1)) {
        ans = mid;
        break;
      } else if (check(arr, n, mid - 1) > check(arr, n, mid) &&
                 check(arr, n, mid) > check(arr, n, mid + 1))
        low = mid + 1;
      else if (check(arr, n, mid - 1) < check(arr, n, mid) &&
               check(arr, n, mid) < check(arr, n, mid + 1))
        high = mid - 1;
    }
    cout << check(arr, n, ans) << " " << ans << endl;
  }
  return 0;
}
