while 1:

    n=int(eval(input()))

    if n==0:break

    a=[int(eval(input())) for _ in range(n)]

    print(((sum(a)-max(a)-min(a))//(n-2)))
while 1:

    n=int(eval(input()))

    if n==0:break

    print(((sum(sorted([int(eval(input())) for _ in range(n)])[1:-1]))//(n-2)))
while 1:
    n = int(eval(input()))
    if n == 0:
        break
    a = [int(eval(input())) for _ in range(n)]
    print(((sum(a) - max(a) - min(a)) // (n - 2)))

while 1:
    n = int(eval(input()))
    if n == 0:
        break
    print(((sum(sorted([int(eval(input())) for _ in range(n)])[1:-1])) // (n - 2)))

-    a = [int(eval(input())) for _ in range(n)] -    print(((sum(a) - max(a) - min(a)) // (n - 2))) +    print(((sum(sorted([int(eval(input())) for _ in range(n)])[1:-1])) // (n - 2)))