#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);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n;
  int i;
  int a[100], count = 0, trip;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] == 1)
      count++;
  }
  trip =
      ((count / 2) + (count % 2) + 1) / 2 + ((count / 2) + (count % 2) + 1) % 2;
  printf("%d\n", trip);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1c0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x1a4(%rbp)
lea    0xebd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b1 <main+0x91>
movslq -0xc(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe88(%rip),%rdi
call   1040 <scanf@plt>
movslq -0xc(%rbp),%rax
cmpl   $0x1,-0x1a0(%rbp,%rax,4)
01
jne    119e <main+0x7e>
mov    -0x1a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1a4(%rbp)
jmp    11a3 <main+0x83>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1153 <main+0x33>
mov    -0x1a4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1b4(%rbp)
mov    -0x1a4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x1b4(%rbp),%eax
add    %edx,%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1ac(%rbp)
mov    -0x1a4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x1b0(%rbp)
mov    -0x1a4(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x1b0(%rbp),%eax
add    %edx,%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x1ac(%rbp),%eax
add    %edx,%eax
mov    %eax,-0x1a8(%rbp)
mov    -0x1a8(%rbp),%esi
lea    0xdc7(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1a8,%rsp
lea    0xecb(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    118a <main+0x6a>
xor    %r12d,%r12d
lea    0x10(%rsp),%rbx
lea    0xeab(%rip),%r14
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xor    %eax,%eax
cmpl   $0x1,(%rbx)
sete   %al
add    %eax,%r15d
add    $0x1,%r12
movslq 0xc(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%r12
jl     1160 <main+0x40>
jmp    118d <main+0x6d>
xor    %r15d,%r15d
mov    %r15d,%eax
shr    %eax
and    $0x1,%r15d
lea    (%r15,%rax,1),%esi
add    $0x1,%esi
mov    %esi,%eax
shr    %eax
and    $0x1,%esi
add    %eax,%esi
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1a8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = bitcast i32* %1 to i8*
%4 = bitcast [100 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 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %0, %8
%9 = phi i64 [ %17, %8 ], [ 0, %0 ]
%10 = phi i32 [ %16, %8 ], [ 0, %0 ]
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %9
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %11)
%13 = load i32, i32* %11
%14 = icmp eq i32 %13, 1
%15 = zext i1 %14 to i32
%16 = add nuw nsw i32 %10, %15
%17 = add nuw nsw i64 %9, 1
%18 = load i32, i32* %1
%19 = sext i32 %18 to i64
%20 = icmp slt i64 %17, %19
br i1 %20, label %8, label %21
21: ; preds = %8, %0
%22 = phi i32 [ 0, %0 ], [ %16, %8 ]
%23 = lshr i32 %22, 1
%24 = and i32 %22, 1
%25 = add nuw nsw i32 %24, 1
%26 = add nuw i32 %25, %23
%27 = lshr i32 %26, 1
%28 = and i32 %26, 1
%29 = add nuw nsw i32 %27, %28
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
ret i32 0
}