#include <stdio.h>
#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

const int INF  = 1 << 30;
const int MINF = -1 * (1 << 30);

int main()
{
    int n;
    int a;
    int maxv;
    int minv;
    int sum;

    while (scanf("%d", &n), n != 0) {
        sum  = 0;
        maxv = MINF;
        minv = INF;

        for (int i = 0; i < n; i++) {
            scanf("%d", &a);

            sum += a;

            maxv = max(maxv, a);
            minv = min(minv, a);
        }

        sum -= maxv;
        sum -= minv;

        printf("%d\n", sum / (n - 2));
    }

    return 0;
}

