import std.stdio;
import std.algorithm;
import std.conv;
import std.string;
import std.range;
import std.math;

void main() {
    while (true) {
        int n = readln.chomp.to!int;
        if (n == 0) break;

        int[] s;
        foreach (i; 0..n) {
            s ~= readln.chomp.to!int;
        }

        writeln((s.reduce!("a + b") - s.minPos[0] - s.minPos!("a > b")[0])
                / (n - 2));
    }
}