#include <stdio.h>

int main(void){
    int h,max,min,t = 0,ave,i,sc;
    while (scanf("%d",&h),h != 0){
        for(i = 1;i <= h; i++){
            scanf("%d",&sc);
            t = t + sc;
            if (i == 1){
                max = sc;
                min = sc;
            }
            else if (max < sc) {
                max = sc;
            }
            else if (min > sc){
                min = sc;
            }
        }
    t = t - min - max;
    h = h - 2;
    ave = t / h;
    printf("%d\n",ave);
    }

    return 0;
}