#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> v(n), vec;
    for (int i = 0; i < n; i++) cin >> v[i];
    for (int i = 0; i < n; i++) {
      if (v[i] == -1) continue;
      if (i - 1 >= 0 && v[i - 1] == -1) vec.push_back(v[i]);
      if (i + 1 < n && v[i + 1] == -1) vec.push_back(v[i]);
    }
    sort(vec.begin(), vec.end());
    long long num, res = -1;
    if (vec.size() == 0) num = 1;
    if (vec.size() == 1) num = vec[0];
    if (vec.size() >= 2) num = (vec[vec.size() - 1] + vec[0]) / 2;
    for (int i = 0; i < n; i++) {
      if (v[i] == -1) v[i] = num;
    }
    for (int i = 0; i < n - 1; i++) {
      res = max(res, abs(v[i] - v[i + 1]));
    }
    cout << res << " " << num << endl;
  }
  return 0;
}
