#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int N = 3e5 + 19;
int T, n;
LL a[N];
int check(int x){
LL sm1 = 0, sm2 = 0;
for(int i=1;i<=n;i++) a[i] > x ? sm2 += (a[i]-x)/2 : sm1 += (x - a[i]);
if(sm1 <= sm2) return 1;
return 0;
}
int main()
{
scanf("%d", &T);
while(T--){
scanf("%d", &n);
for(int i = 1; i <= n; i ++) scanf("%lld", &a[i]);
int l = 0, r = 100000000, mid;
while(l<=r){
mid = (l+r)>>1;
if(check(mid)) l = mid+1;
else r = mid-1;
}
printf("%d\n", l-1);
}
return 0;
}
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int LL;
const int N = 3e5 + 19;
int T, n;
LL a[N], sum[N], cnt[N];
int check(int x){
int p1 = lower_bound(a+1, a+1+n, x) - a;
int p2 = upper_bound(a+1, a+1+n, x) - a;
int p = n - p2 + 1;
p1 --;
LL sm1 = 1LL * p1 * x - sum[p1], sm2 = sum[n] - sum[p2-1] - 1LL * p * x;
if(x&1){
sm2 = sm2 - (cnt[n] - cnt[p2-1]);
} else {
sm2 = sm2 - (p - cnt[n] + cnt[p2-1]);
}
sm2 /= 2;
if(sm1 <= sm2) return 1;
return 0;
}
int main()
{
scanf("%d", &T);
while(T--){
scanf("%d", &n);
for(int i = 1; i <= n; i ++) {
scanf("%lld", &a[i]);
}
sort(a+1, a+1+n);
for(int i=1;i<=n;i++) {
cnt[i] = cnt[i-1];
if(a[i] % 2 == 0) cnt[i] ++;
sum[i] = sum[i-1] + a[i];
}
int l = 0, r = 100000000, mid;
while(l<=r){
mid = (l+r)>>1;
if(check(mid)) l = mid+1;
else r = mid-1;
}
printf("%d\n", l-1);
}
return 0;
}