while True:

    n = int(eval(input()))

    if not(n): break

    s = sum(sorted([int(eval(input())) for i in range(n)])[1:-1])

    print((s//(n-2)))
while True:

    n = int(eval(input()))

    if n==0: break

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

    print(a)
while True:
    n = int(eval(input()))
    if not (n):
        break
    s = sum(sorted([int(eval(input())) for i in range(n)])[1:-1])
    print((s // (n - 2)))

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

-    if not (n): +    if n == 0: -    s = sum(sorted([int(eval(input())) for i in range(n)])[1:-1]) -    print((s // (n - 2))) +    a = sum(sorted([int(eval(input())) for _ in range(n)])[1:-1]) // (n - 2) +    print(a)