#include <stdio.h>

int main(void)
{
    int n, d;
    int i;

    while (1)
    {
        int sum = 0, min, max;
        scanf("%d", &n);
        if (n == 0)
            break;

        for (i = 0; i < n; i++)
        {
            scanf("%d", &d);
            if (i == 0)
            {
                max = d;
                min = d;
            }
            if (d > max)
                max = d;
            if (d < min)
                min = d;
            sum += d;
        }
        sum -= max + min;
        printf("%d\n", sum / (n - 2));
    }
    return 0;
}
