#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ qsort(int *, int /*<<< orphan*/, int);
scalar_t__ scanf(char *, int *);
int main() {
  int a[10000], n, i, j, flag, t;
  while (scanf("%d", &n) != EOF) {
    if (n == 0)
      break;
    for (i = 0; i < n; i++)
      scanf("%d", &a[i]);
    qsort(a, 0, n - 1);
    if (n % 2 == 0)
      printf("%d\n", (a[n / 2 - 1] + a[n / 2]) / 2);
    else
      printf("%d\n", a[n / 2]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x9c70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x9c54(%rbp),%rsi
call   1050 <scanf@plt>
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%rax
je     1279 <main+0x149>
cmpl   $0x0,-0x9c54(%rbp)
jne    1177 <main+0x47>
jmp    1279 <main+0x149>
movl   $0x0,-0x9c58(%rbp)
mov    -0x9c58(%rbp),%eax
cmp    -0x9c54(%rbp),%eax
jge    11c8 <main+0x98>
movslq -0x9c58(%rbp),%rax
lea    -0x9c50(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe51(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x9c58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c58(%rbp)
jmp    1181 <main+0x51>
lea    -0x9c50(%rbp),%rdi
mov    -0x9c54(%rbp),%edx
sub    $0x1,%edx
xor    %esi,%esi
call   1030 <qsort@plt>
mov    -0x9c54(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1251 <main+0x121>
mov    -0x9c54(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
cltq
mov    -0x9c50(%rbp,%rax,4),%eax
mov    %eax,-0x9c68(%rbp)
mov    -0x9c54(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x9c68(%rbp),%eax
movslq %ecx,%rcx
add    -0x9c50(%rbp,%rcx,4),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xdbc(%rip),%rdi
call   1040 <printf@plt>
jmp    1274 <main+0x144>
mov    -0x9c54(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
mov    -0x9c50(%rbp,%rax,4),%esi
lea    0xd94(%rip),%rdi
call   1040 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x9c70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x9c58,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
je     122f <main+0xff>
mov    0xc(%rsp),%edx
test   %edx,%edx
je     122f <main+0xff>
lea    0x10(%rsp),%r14
lea    0xe86(%rip),%r13
lea    0xe82(%rip),%r15
lea    0xc(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
test   %edx,%edx
jle    11bd <main+0x8d>
mov    %r14,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %r13,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rdx
add    $0x4,%rbx
cmp    %rdx,%rbp
jl     11a0 <main+0x70>
add    $0xffffffff,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <qsort@plt>
mov    0xc(%rsp),%ecx
mov    %ecx,%eax
shr    $0x1f,%eax
add    %ecx,%eax
sar    %eax
cltq
test   $0x1,%cl
jne    1200 <main+0xd0>
mov    0x10(%rsp,%rax,4),%ecx
add    0xc(%rsp,%rax,4),%ecx
mov    %ecx,%esi
shr    $0x1f,%esi
add    %ecx,%esi
sar    %esi
jmp    1204 <main+0xd4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp,%rax,4),%esi
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r13,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x2dca(%rip),%rcx
cmp    (%rcx),%rax
je     122f <main+0xff>
mov    0xc(%rsp),%edx
test   %edx,%edx
jne    1190 <main+0x60>
xor    %eax,%eax
add    $0x9c58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10000 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
br label %8
8: ; preds = %59, %0
%9 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%10 = load i64, i64* @EOF
%11 = icmp ne i64 %9, %10
br i1 %11, label %12, label %60
12: ; preds = %8
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %12
br label %60
16: ; preds = %12
store i32 0, i32* %4
br label %17
17: ; preds = %26, %16
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [10000 x i32], [10000 x i32]* %2, i64 0, i64 %23
%25 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %21
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %17
29: ; preds = %17
%30 = getelementptr inbounds [10000 x i32], [10000 x i32]* %2, i64 0, i64 0
%31 = load i32, i32* %3
%32 = sub nsw i32 %31, 1
%33 = call i32 @qsort(i32* %30, i32 0, i32 %32)
%34 = load i32, i32* %3
%35 = srem i32 %34, 2
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %52
37: ; preds = %29
%38 = load i32, i32* %3
%39 = sdiv i32 %38, 2
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [10000 x i32], [10000 x i32]* %2, i64 0, i64 %41
%43 = load i32, i32* %42
%44 = load i32, i32* %3
%45 = sdiv i32 %44, 2
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [10000 x i32], [10000 x i32]* %2, i64 0, i64 %46
%48 = load i32, i32* %47
%49 = add nsw i32 %43, %48
%50 = sdiv i32 %49, 2
%51 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %50)
br label %59
52: ; preds = %29
%53 = load i32, i32* %3
%54 = sdiv i32 %53, 2
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [10000 x i32], [10000 x i32]* %2, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %52, %37
br label %8
60: ; preds = %15, %8
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [10000 x i32]
%2 = alloca i32
%3 = bitcast [10000 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
%8 = load i32, i32* %2
%9 = icmp eq i32 %8, 0
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %55, label %11
11: ; preds = %0
%12 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 0
br label %13
13: ; preds = %11, %46
%14 = phi i32 [ %8, %11 ], [ %52, %46 ]
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %13, %16
%17 = phi i64 [ %20, %16 ], [ 0, %13 ]
%18 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %17
%19 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %18)
%20 = add nuw nsw i64 %17, 1
%21 = load i32, i32* %2
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %16, label %24
24: ; preds = %16, %13
%25 = phi i32 [ %14, %13 ], [ %21, %16 ]
%26 = add nsw i32 %25, -1
%27 = call i32 @qsort(i32* %12, i32 0, i32 %26)
%28 = load i32, i32* %2
%29 = and i32 %28, 1
%30 = icmp eq i32 %29, 0
%31 = sdiv i32 %28, 2
br i1 %30, label %32, label %42
32: ; preds = %24
%33 = add nsw i32 %31, -1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = sext i32 %31 to i64
%38 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = add nsw i32 %39, %36
%41 = sdiv i32 %40, 2
br label %46
42: ; preds = %24
%43 = sext i32 %31 to i64
%44 = getelementptr inbounds [10000 x i32], [10000 x i32]* %1, i64 0, i64 %43
%45 = load i32, i32* %44
br label %46
46: ; preds = %42, %32
%47 = phi i32 [ %45, %42 ], [ %41, %32 ]
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%50 = load i64, i64* @EOF
%51 = icmp eq i64 %49, %50
%52 = load i32, i32* %2
%53 = icmp eq i32 %52, 0
%54 = select i1 %51, i1 true, i1 %53
br i1 %54, label %55, label %13
55: ; preds = %46, %0
ret i32 0
}