#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 */
int EXIT_SUCCESS;
scalar_t__ abs(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ sort(int *, int);
int /*<<< orphan*/ stdin;
int main(void) {
  int i, count, door[20], middle, sum = 0;
  printf("½Ð¿é¤J¿Ë±­¼Æ¶q¡G");
  fflush(stdin);
  scanf("%d", &count);
  if ((count <= 1) || (count >= 20)) {
    printf("½Ð¿é¤J1~20ªº¼Æ¦r!!!\7\7\7");
    return 0;
  }
  printf("½Ð¿é¤J%dµ§¿Ë±­®aªºªù¸¹¡G", count);
  for (i = 0; i < count; i++)
    scanf("%d", &door[i]);
  sort(door, count);
  middle = door[count / 2];
  for (i = 0; i < count; i++)
    sum += abs(middle - door[i]);
  printf("¨ì¦U­Ó¿Ë±­®aªºÁ`©M¡G\n%d", sum);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x68(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xf06(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jle    11a6 <main+0x56>
cmpl   $0x14,-0xc(%rbp)
jl     11c0 <main+0x70>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1288 <main+0x138>
mov    -0xc(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    120d <main+0xbd>
movslq -0x8(%rbp),%rax
lea    -0x60(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe95(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d8 <main+0x88>
lea    -0x60(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <sort@plt>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cltq
mov    -0x60(%rbp,%rax,4),%eax
mov    %eax,-0x64(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    126b <main+0x11b>
mov    -0x64(%rbp),%edi
movslq -0x8(%rbp),%rax
sub    -0x60(%rbp,%rax,4),%edi
call   1030 <abs@plt>
mov    %rax,%rcx
movslq -0x68(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x68(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1234 <main+0xe4>
mov    -0x68(%rbp),%esi
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xe9f(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
lea    0xf10(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%esi
lea    -0x14(%rsi),%eax
cmp    $0xffffffed,%eax
ja     11a8 <main+0x58>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1257 <main+0x107>
lea    0xe90(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
jle    11ed <main+0x9d>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
lea    0xec0(%rip),%r14
nop
mov    %r14,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
add    $0x1,%rbp
movslq 0xc(%rsp),%rsi
add    $0x4,%rbx
cmp    %rsi,%rbp
jl     11d0 <main+0x80>
lea    0x10(%rsp),%rdi
call   1050 <sort@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    123d <main+0xed>
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
movslq %ecx,%rax
mov    0x10(%rsp,%rax,4),%r14d
xor    %ebx,%ebx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14d,%edi
sub    0x10(%rsp,%rbx,4),%edi
call   1030 <abs@plt>
add    %eax,%r15d
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1220 <main+0xd0>
lea    0xe27(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d83(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"\C2\BD\C3\90\C2\BF\C3\A9\C2\A4J\C2\BF\C3\8B\C2\B1\C2\AD\C2\BC\C3\86\C2\B6q\C2\A1G\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"\C2\BD\C3\90\C2\BF\C3\A9\C2\A4J1~20\C2\AA\C2\BA\C2\BC\C3\86\C2\A6r!!!\07\07\07\00"
@.str.3 = [44 x i8] c"\C2\BD\C3\90\C2\BF\C3\A9\C2\A4J%d\C2\B5\C2\A7\C2\BF\C3\8B\C2\B1\C2\AD\C2\AEa\C2\AA\C2\BA\C2\AA\C3\B9\C2\B8\C2\B9\C2\A1G\00"
@.str.4 = [39 x i8] c"\C2\A8\C3\AC\C2\A6U\C2\AD\C3\93\C2\BF\C3\8B\C2\B1\C2\AD\C2\AEa\C2\AA\C2\BA\C3\81`\C2\A9M\C2\A1G\0A%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i32]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stdin
%9 = call i32 @fflush(i32 %8)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = icmp sle i32 %11, 1
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = load i32, i32* %3
%15 = icmp sge i32 %14, 20
br i1 %15, label %16, label %18
16: ; preds = %13, %0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %65
18: ; preds = %13
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %19)
store i32 0, i32* %2
br label %21
21: ; preds = %30, %18
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %33
25: ; preds = %21
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %27
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %28)
br label %30
30: ; preds = %25
%31 = load i32, i32* %2
%32 = add nsw i32 %31, 1
store i32 %32, i32* %2
br label %21
33: ; preds = %21
%34 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 0
%35 = load i32, i32* %3
%36 = call i32 @sort(i32* %34, i32 %35)
%37 = load i32, i32* %3
%38 = sdiv i32 %37, 2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %39
%41 = load i32, i32* %40
store i32 %41, i32* %5
store i32 0, i32* %2
br label %42
42: ; preds = %58, %33
%43 = load i32, i32* %2
%44 = load i32, i32* %3
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %61
46: ; preds = %42
%47 = load i32, i32* %5
%48 = load i32, i32* %2
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [20 x i32], [20 x i32]* %4, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = sub nsw i32 %47, %51
%53 = call i64 @abs(i32 %52)
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = add nsw i64 %55, %53
%57 = trunc i64 %56 to i32
store i32 %57, i32* %6
br label %58
58: ; preds = %46
%59 = load i32, i32* %2
%60 = add nsw i32 %59, 1
store i32 %60, i32* %2
br label %42
61: ; preds = %42
%62 = load i32, i32* %6
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %62)
%64 = load i32, i32* @EXIT_SUCCESS
store i32 %64, i32* %1
br label %65
65: ; preds = %61, %16
%66 = load i32, i32* %1
ret i32 %66
}

LLVM IR (-O2):
@.str = [30 x i8] c"\C2\BD\C3\90\C2\BF\C3\A9\C2\A4J\C2\BF\C3\8B\C2\B1\C2\AD\C2\BC\C3\86\C2\B6q\C2\A1G\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"\C2\BD\C3\90\C2\BF\C3\A9\C2\A4J1~20\C2\AA\C2\BA\C2\BC\C3\86\C2\A6r!!!\07\07\07\00"
@.str.3 = [44 x i8] c"\C2\BD\C3\90\C2\BF\C3\A9\C2\A4J%d\C2\B5\C2\A7\C2\BF\C3\8B\C2\B1\C2\AD\C2\AEa\C2\AA\C2\BA\C2\AA\C3\B9\C2\B8\C2\B9\C2\A1G\00"
@.str.4 = [39 x i8] c"\C2\A8\C3\AC\C2\A6U\C2\AD\C3\93\C2\BF\C3\8B\C2\B1\C2\AD\C2\AEa\C2\AA\C2\BA\C3\81`\C2\A9M\C2\A1G\0A%d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [20 x i32]* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @stdin
%7 = tail call i32 @fflush(i32 %6)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = add i32 %9, -20
%11 = icmp ult i32 %10, -18
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %53
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %9)
%16 = load i32, i32* %1
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %14, %18
%19 = phi i64 [ %22, %18 ], [ 0, %14 ]
%20 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %19
%21 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %20)
%22 = add nuw nsw i64 %19, 1
%23 = load i32, i32* %1
%24 = sext i32 %23 to i64
%25 = icmp slt i64 %22, %24
br i1 %25, label %18, label %26
26: ; preds = %18, %14
%27 = phi i32 [ %16, %14 ], [ %23, %18 ]
%28 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 0
%29 = call i32 @sort(i32* %28, i32 %27)
%30 = load i32, i32* %1
%31 = sdiv i32 %30, 2
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = icmp sgt i32 %30, 0
br i1 %35, label %36, label %49
36: ; preds = %26, %36
%37 = phi i64 [ %45, %36 ], [ 0, %26 ]
%38 = phi i32 [ %44, %36 ], [ 0, %26 ]
%39 = getelementptr inbounds [20 x i32], [20 x i32]* %2, i64 0, i64 %37
%40 = load i32, i32* %39
%41 = sub nsw i32 %34, %40
%42 = call i64 @abs(i32 %41)
%43 = trunc i64 %42 to i32
%44 = add i32 %38, %43
%45 = add nuw nsw i64 %37, 1
%46 = load i32, i32* %1
%47 = sext i32 %46 to i64
%48 = icmp slt i64 %45, %47
br i1 %48, label %36, label %49
49: ; preds = %36, %26
%50 = phi i32 [ 0, %26 ], [ %44, %36 ]
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i32 %50)
%52 = load i32, i32* @EXIT_SUCCESS
br label %53
53: ; preds = %49, %12
%54 = phi i32 [ 0, %12 ], [ %52, %49 ]
ret i32 %54
}