#include <stdio.h>

typedef int value_type; /* ??????????????????????????? */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z ????????????????????? */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right)
/* ?????????????????????
 * a     : ?????????????????????
 * left  : ???????????????????????????????§???????
 * right : ???????????????????????????????????????
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2??§??????????????????????????????????????? */
        while (1) { /* a[] ??? pivot ??\?????¨??\?????????????????????????????? */
            while (a[i] < pivot) i++; /* a[i] >= pivot ??¨???????????????????´¢ */
            while (pivot < a[j]) j--; /* a[j] <= pivot ??¨???????????????????´¢ */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] ????????? */
            i++; j--;
        }
        quicksort(a, left, i - 1);  /* ???????????????????????°??????????????? */
        quicksort(a, j + 1, right); /* ???????????????????????°??????????????? */
    }
}


int main () {

	int dataset=0;
	int dataset_num=0;
	int input=0;
	int count=0;
	int number=1;
	int mul=1;

	int result1=0;
	int result2=0;
	char f_result=0;

	int point[100];
	int max=0;
	int cul=0;


	scanf("%d",&dataset);
	dataset_num = dataset;

	while( dataset != 0 ){
		count=0;

		while(1){
			scanf("%d",&point[count]);
			if(point[count] == 0 ){
				//printf("input finish\n");
				break;
			}
			count++;
		}


		//??????????§?
		int i=0;
		int number;
		count--;
		max = count;

		/*
		//??¨?????????
		int tamesi=count;
		int x=0;
		while(1){
			printf("%d ",point[x] );
			x++;

			if(point[x]==0){
				//printf("\ndisplay finish\n");
				break;
			}
		}
		//??¨??????????????????
		*/

		

		quicksort(point,0,count);

		
		count=1;
		while(1){
			cul += point[count];
			count++;
			if(max == count){
				printf("\n");
				break;
			}
		}
		cul = cul / (max-1);
		
		


		printf("%d\n",cul );

		dataset--;
		input++;

	}
		


	return 0;
}