#include <bits/stdc++.h>
using namespace std;
int t;
int n;
int a[100005];
int m, k;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    int ans = 0;
    int ans1 = 0;
    int flag1 = 0;
    int flag2 = 1e9 + 5;
    m = 0;
    k = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] != -1) {
        ans++;
        ans1 = a[i];
      }
    }
    if (ans == 0) {
      cout << 0 << " " << 0 << endl;
    } else if (ans == 1) {
      cout << 0 << " " << ans1 << endl;
    } else {
      for (int i = 1; i <= n; i++) {
        if (a[i] == -1 && i == 1 && a[i + 1] != -1) {
          flag1 = max(flag1, a[i + 1]);
          flag2 = min(flag2, a[i + 1]);
        } else if (a[i] == -1 && i > 1 && i < n) {
          if (a[i - 1] != -1) {
            flag1 = max(flag1, a[i - 1]);
            flag2 = min(flag2, a[i - 1]);
          }
          if (a[i + 1] != -1) {
            flag1 = max(flag1, a[i + 1]);
            flag2 = min(flag2, a[i + 1]);
          }
        } else if (a[i] == -1 && i == n && a[i - 1] != -1) {
          flag1 = max(flag1, a[i - 1]);
          flag2 = min(flag2, a[i - 1]);
        }
      }
      k = (flag1 + flag2) / 2;
      for (int i = 1; i <= n; i++) {
        if (a[i] == -1) {
          a[i] = k;
        }
        if (i >= 2) {
          m = max(m, abs(a[i] - a[i - 1]));
        }
      }
      cout << m << " " << k << endl;
    }
  }
  return 0;
}
