#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int t;
while(scanf("%d",&t)!=EOF){
while(t--){
int n,a[1001];
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
sort(a,a+n);
printf("%d ",a[n-1]);
for(int i=n-2;i>=0;i--){
if(a[i]!=a[n-1]){
printf("%d\n",a[i]);
break;
}
}
}
}
return 0;
}
#include<algorithm>
using namespace std;
int main()
{
int t;
while(scanf("%d",&t)!=EOF){
while(t--){
int n,a[1001];
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%d",&a[i]);
sort(a,a+n);
printf("%d ",a[n-1]);
for(int i=n-2;i>=0;i--){
if(a[i]!=a[n-1]){
printf("%d\n",a[i]);
break;
}
}
}
}
return 0;
}