#include <stdio.h>

int main(void) {
    int i, n, max, min, ans ,tmp;
    int array[101];
    scanf("%d",&n);
    while(n) {
        scanf("%d",&tmp);
        ans = 0;
        array[0] = tmp;
        max = tmp;
        min = tmp;
        for(i = 1; i < n; i++ ) {
            scanf("%d",&array[i]);
            if(min > array[i]) {
                min = array[i];
            }
            if(max < array[i]) {
                max = array[i];
            }
        }
        for(i = 0; i < n; i++ ) {
            ans += array[i];
        }
        ans -= (min + max);
        printf("%d\n",ans/(n-2));
        scanf("%d",&n);
    }
    return 0;
}