#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n, arr[4] = {0};
  scanf("%d", &n);
  while (n--) {
    scanf("%d", &arr[0]);
    arr[arr[0]]++;
  }
  while (arr[1]--)
    printf("1 ");
  while (arr[2]--)
    printf("2 ");
  while (arr[3]--)
    printf("3 ");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1040 <memset@plt>
lea    0xeaa(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     1197 <main+0x67>
lea    -0x20(%rbp),%rsi
lea    0xe82(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x20(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    115f <main+0x2f>
jmp    119c <main+0x6c>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     11c1 <main+0x91>
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
jmp    119c <main+0x6c>
jmp    11c6 <main+0x96>
mov    -0x18(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x18(%rbp)
cmp    $0x0,%eax
je     11eb <main+0xbb>
lea    0xe25(%rip),%rdi
call   1030 <printf@plt>
jmp    11c6 <main+0x96>
jmp    11f0 <main+0xc0>
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     1215 <main+0xe5>
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
jmp    11f0 <main+0xc0>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xeca(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1151 <main+0x31>
movl   $0xffffffff,0x14(%rsp)
ff
jmp    119f <main+0x7f>
lea    0xea8(%rip),%r14
lea    0x10(%rsp),%rbx
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movslq 0x10(%rsp),%rax
addl   $0x1,0x10(%rsp,%rax,4)
subl   $0x1,0xc(%rsp)
jae    1160 <main+0x40>
subl   $0x1,0x14(%rsp)
jb     119f <main+0x7f>
lea    0xe79(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <printf@plt>
subl   $0x1,0x14(%rsp)
jae    1190 <main+0x70>
subl   $0x1,0x18(%rsp)
jb     11bf <main+0x9f>
lea    0xe59(%rip),%rbx
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <printf@plt>
subl   $0x1,0x18(%rsp)
jae    11b0 <main+0x90>
subl   $0x1,0x1c(%rsp)
jb     11df <main+0xbf>
lea    0xe3c(%rip),%rbx
nopl   (%rax)
mov    %rbx,%rdi
call   1030 <printf@plt>
subl   $0x1,0x1c(%rsp)
jae    11d0 <main+0xb0>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"1 \00"
@.str.2 = [3 x i8] c"2 \00"
@.str.3 = [3 x i8] c"3 \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [4 x i32]
store i32 0, i32* %1
%4 = bitcast [4 x i32]* %3 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %2
%8 = add nsw i32 %7, -1
store i32 %8, i32* %2
%9 = icmp ne i32 %7, 0
br i1 %9, label %10, label %19
10: ; preds = %6
%11 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 0
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 %15
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
br label %6
19: ; preds = %6
br label %20
20: ; preds = %25, %19
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 1
%22 = load i32, i32* %21
%23 = add nsw i32 %22, -1
store i32 %23, i32* %21
%24 = icmp ne i32 %22, 0
br i1 %24, label %25, label %27
25: ; preds = %20
%26 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %20
27: ; preds = %20
br label %28
28: ; preds = %33, %27
%29 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 2
%30 = load i32, i32* %29
%31 = add nsw i32 %30, -1
store i32 %31, i32* %29
%32 = icmp ne i32 %30, 0
br i1 %32, label %33, label %35
33: ; preds = %28
%34 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %28
35: ; preds = %28
br label %36
36: ; preds = %41, %35
%37 = getelementptr inbounds [4 x i32], [4 x i32]* %3, i64 0, i64 3
%38 = load i32, i32* %37
%39 = add nsw i32 %38, -1
store i32 %39, i32* %37
%40 = icmp ne i32 %38, 0
br i1 %40, label %41, label %43
41: ; preds = %36
%42 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %36
43: ; preds = %36
ret i32 0
}

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