/*
Mail to : miyubai@gamil.com
My Blog : www.baiyun.me
Link : http://www.cnblogs.com/MiYu || http://www.cppblog.com/MiYu
Author By : MiYu
Test : 1
Complier : g++ mingw32-3.4.2
Program : HDU_2561
Doc Name : 第二小整数
*/
//#pragma warning( disable:4789 )
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <utility>
#include <queue>
#include <stack>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;
int a[20];
int main ()
{
int T;
scanf ( "%d", &T );
while ( T -- ) {
int N;
scanf ( "%d", &N );
for ( int i = 0; i < N; ++ i ) {
scanf ( "%d", a+i );
}
sort ( a, a+N );
printf ( "%d\n", a[1] );
}
return 0;
}