#include <bits/stdc++.h>
using namespace std;
long long func(long long n) {
  return ((n - 1) * (n)) - (((n - 2) * (n - 1)) / 2) + 1;
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    set<int> adj;
    for (int i = 0; i < n; i++)
      if (a[i] == -1) {
        if (i + 1 < n) adj.insert(a[i + 1]);
        if (i - 1 >= 0) adj.insert(a[i - 1]);
      }
    adj.erase(-1);
    if (adj.size() == 0) {
      cout << "0 7\n";
      continue;
    }
    double mn = *min_element(adj.begin(), adj.end());
    double mx = *max_element(adj.begin(), adj.end());
    int k = round((mn + mx) / 2.0);
    int m = 0;
    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]));
    cout << m << ' ' << k << '\n';
  }
}
