#include <bits/stdc++.h>
using namespace std;
// hàm tìm số lớn thứ 1
int max1N (int a[], int n) {
int tmp=-1e9;
for (int i=0; i<n; i++) {
if (a[i]>tmp) tmp= a[i];
}
return tmp;
}
// hàm tìm số lớn thứ 2
int max2N (int a[], int n, int res1) {
int tmp=-1e9;
for (int i=0; i<n; i++) {
if (a[i]>tmp && a[i]<res1) tmp= a[i];
}
return tmp;
}
int main () {
ios_base:: sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
while (t--) {
int n; cin >> n;
int a[n];
for (int i=0; i<n; i++) cin >> a[i];
int res1= max1N (a, n);
int res2= max2N (a, n, res1);
// nếu không tìm được res2 -> res2 mặc định là -1e9
if (res2==-1e9) cout << "0" << endl;
else cout << res2 << " " << res1 << endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKLy8gaMOgbSB0w6xtIHPhu5EgbOG7m24gdGjhu6kgMQppbnQgbWF4MU4gKGludCBhW10sIGludCBuKSB7CglpbnQgdG1wPS0xZTk7Cglmb3IgKGludCBpPTA7IGk8bjsgaSsrKSB7CgkJaWYgKGFbaV0+dG1wKSB0bXA9IGFbaV07Cgl9CglyZXR1cm4gdG1wOwp9CiAKLy8gaMOgbSB0w6xtIHPhu5EgbOG7m24gdGjhu6kgMgppbnQgbWF4Mk4gKGludCBhW10sIGludCBuLCBpbnQgcmVzMSkgewoJaW50IHRtcD0tMWU5OwoJZm9yIChpbnQgaT0wOyBpPG47IGkrKykgewoJCWlmIChhW2ldPnRtcCAmJiBhW2ldPHJlczEpIHRtcD0gYVtpXTsKCX0KCXJldHVybiB0bXA7Cn0KIAppbnQgbWFpbiAoKSB7Cglpb3NfYmFzZTo6IHN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CgljaW4udGllKG51bGxwdHIpOwogCglpbnQgdDsgY2luID4+IHQ7Cgl3aGlsZSAodC0tKSB7CgkJaW50IG47IGNpbiA+PiBuOwoJCWludCBhW25dOwoJCWZvciAoaW50IGk9MDsgaTxuOyBpKyspIGNpbiA+PiBhW2ldOwogCgkJaW50IHJlczE9IG1heDFOIChhLCBuKTsKCQlpbnQgcmVzMj0gbWF4Mk4gKGEsIG4sIHJlczEpOwogCgkJLy8gbuG6v3Uga2jDtG5nIHTDrG0gxJHGsOG7o2MgcmVzMiAtPiByZXMyIG3hurdjIMSR4buLbmggbMOgIC0xZTkKCQlpZiAocmVzMj09LTFlOSkgY291dCA8PCAiMCIgPDwgZW5kbDsKCQllbHNlIGNvdXQgPDwgcmVzMiA8PCAiICIgPDwgcmVzMSA8PCBlbmRsOwoJfQp9