#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*/ freopen(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long long *);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  freopen("even.in", "r", stdin);
  freopen("even.out", "w+", stdout);
  long long n, last_num[10001], last_index = -1;
  scanf("%I64d", &n);
  while (n--) {
    last_index++;
    scanf("%I64d", &last_num[last_index]);
    last_num[last_index] &= last_num[last_index];
    while (!(last_num[last_index] + last_num[last_index - 1] & 1) &&
           last_index > 0) {
      last_index--;
      last_index--;
    }
    last_num[last_index] &= last_num[last_index];
  }
  printf("%I64d", ++last_index);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
lea    0xea7(%rip),%rdi
lea    0xea8(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edx
lea    0xe95(%rip),%rdi
lea    0xe97(%rip),%rsi
call   1040 <freopen@plt>
movq   $0xffffffffffffffff,-0x138a8(%rbp)
ff ff ff ff
lea    0xe83(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     12be <main+0x18e>
mov    -0x138a8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x138a8(%rbp)
mov    -0x138a8(%rbp),%rax
lea    -0x138a0(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe33(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x138a8(%rbp),%rax
mov    -0x138a0(%rbp,%rax,8),%rcx
ff
mov    -0x138a8(%rbp),%rax
and    -0x138a0(%rbp,%rax,8),%rcx
ff
mov    %rcx,-0x138a0(%rbp,%rax,8)
ff
mov    -0x138a8(%rbp),%rax
mov    -0x138a0(%rbp,%rax,8),%rcx
ff
mov    -0x138a8(%rbp),%rax
sub    $0x1,%rax
add    -0x138a0(%rbp,%rax,8),%rcx
ff
and    $0x1,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x138a9(%rbp)
jne    1257 <main+0x127>
cmpq   $0x0,-0x138a8(%rbp)
setg   %al
mov    %al,-0x138a9(%rbp)
mov    -0x138a9(%rbp),%al
test   $0x1,%al
jne    126a <main+0x13a>
jmp    1293 <main+0x163>
mov    -0x138a8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x138a8(%rbp)
mov    -0x138a8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x138a8(%rbp)
jmp    120e <main+0xde>
mov    -0x138a8(%rbp),%rax
mov    -0x138a0(%rbp,%rax,8),%rcx
ff
mov    -0x138a8(%rbp),%rax
and    -0x138a0(%rbp,%rax,8),%rcx
ff
mov    %rcx,-0x138a0(%rbp,%rax,8)
ff
jmp    119c <main+0x6c>
mov    -0x138a8(%rbp),%rsi
add    $0x1,%rsi
mov    %rsi,-0x138a8(%rbp)
lea    0xd3f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x138b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x13898,%rsp
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
lea    0xeb6(%rip),%rdi
lea    0xeb7(%rip),%rsi
call   1040 <freopen@plt>
mov    0x2e7b(%rip),%rax
mov    (%rax),%edx
lea    0xea4(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1040 <freopen@plt>
lea    0xe9d(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    $0xffffffffffffffff,%rsi
subq   $0x1,0x8(%rsp)
jb     11ee <main+0xbe>
mov    $0xffffffffffffffff,%rbx
lea    0xe76(%rip),%r14
jmp    11bc <main+0x8c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0x2(%rsi),%rbx
subq   $0x1,0x8(%rsp)
jb     11ea <main+0xba>
lea    (%rsp,%rbx,8),%rsi
add    $0x18,%rsi
add    $0x1,%rbx
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x8(%rsp,%rbx,8),%eax
add    0x10(%rsp,%rbx,8),%eax
lea    -0x2(%rbx),%rsi
test   $0x1,%al
jne    11b0 <main+0x80>
test   %rbx,%rbx
mov    %rsi,%rbx
jg     11d0 <main+0xa0>
jmp    11b0 <main+0x80>
add    $0x2,%rsi
add    $0x1,%rsi
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x13898,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"even.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"even.out\00"
@.str.3 = [3 x i8] c"w+\00"
@stdout = global i32 0
@.str.4 = [6 x i8] c"%I64d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca [10001 x i64]
%8 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @stdin
%10 = call i32 @freopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @stdout
%12 = call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %11)
store i64 -1, i64* %8
%13 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64* %6)
br label %14
14: ; preds = %52, %2
%15 = load i64, i64* %6
%16 = add nsw i64 %15, -1
store i64 %16, i64* %6
%17 = icmp ne i64 %15, 0
br i1 %17, label %18, label %60
18: ; preds = %14
%19 = load i64, i64* %8
%20 = add nsw i64 %19, 1
store i64 %20, i64* %8
%21 = load i64, i64* %8
%22 = getelementptr inbounds [10001 x i64], [10001 x i64]* %7, i64 0, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64* %22)
%24 = load i64, i64* %8
%25 = getelementptr inbounds [10001 x i64], [10001 x i64]* %7, i64 0, i64 %24
%26 = load i64, i64* %25
%27 = load i64, i64* %8
%28 = getelementptr inbounds [10001 x i64], [10001 x i64]* %7, i64 0, i64 %27
%29 = load i64, i64* %28
%30 = and i64 %29, %26
store i64 %30, i64* %28
br label %31
31: ; preds = %47, %18
%32 = load i64, i64* %8
%33 = getelementptr inbounds [10001 x i64], [10001 x i64]* %7, i64 0, i64 %32
%34 = load i64, i64* %33
%35 = load i64, i64* %8
%36 = sub nsw i64 %35, 1
%37 = getelementptr inbounds [10001 x i64], [10001 x i64]* %7, i64 0, i64 %36
%38 = load i64, i64* %37
%39 = add nsw i64 %34, %38
%40 = and i64 %39, 1
%41 = icmp ne i64 %40, 0
br i1 %41, label %45, label %42
42: ; preds = %31
%43 = load i64, i64* %8
%44 = icmp sgt i64 %43, 0
br label %45
45: ; preds = %42, %31
%46 = phi i1 [ false, %31 ], [ %44, %42 ]
br i1 %46, label %47, label %52
47: ; preds = %45
%48 = load i64, i64* %8
%49 = add nsw i64 %48, -1
store i64 %49, i64* %8
%50 = load i64, i64* %8
%51 = add nsw i64 %50, -1
store i64 %51, i64* %8
br label %31
52: ; preds = %45
%53 = load i64, i64* %8
%54 = getelementptr inbounds [10001 x i64], [10001 x i64]* %7, i64 0, i64 %53
%55 = load i64, i64* %54
%56 = load i64, i64* %8
%57 = getelementptr inbounds [10001 x i64], [10001 x i64]* %7, i64 0, i64 %56
%58 = load i64, i64* %57
%59 = and i64 %58, %55
store i64 %59, i64* %57
br label %14
60: ; preds = %14
%61 = load i64, i64* %8
%62 = add nsw i64 %61, 1
store i64 %62, i64* %8
%63 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [8 x i8] c"even.in\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [9 x i8] c"even.out\00"
@.str.3 = [3 x i8] c"w+\00"
@stdout = global i32 0
@.str.4 = [6 x i8] c"%I64d\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i64
%4 = alloca [10001 x i64]
%5 = load i32, i32* @stdin
%6 = tail call i32 @freopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @stdout
%8 = tail call i32 @freopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = bitcast i64* %3 to i8*
%10 = bitcast [10001 x i64]* %4 to i8*
%11 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64* %3)
%12 = load i64, i64* %3
%13 = add nsw i64 %12, -1
store i64 %13, i64* %3
%14 = icmp eq i64 %12, 0
br i1 %14, label %37, label %19
15: ; preds = %24
%16 = load i64, i64* %3
%17 = add nsw i64 %16, -1
store i64 %17, i64* %3
%18 = icmp eq i64 %16, 0
br i1 %18, label %37, label %19
19: ; preds = %2, %15
%20 = phi i64 [ %25, %15 ], [ -1, %2 ]
%21 = add nsw i64 %20, 1
%22 = getelementptr inbounds [10001 x i64], [10001 x i64]* %4, i64 0, i64 %21
%23 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64* %22)
br label %24
24: ; preds = %24, %19
%25 = phi i64 [ %21, %19 ], [ %36, %24 ]
%26 = getelementptr inbounds [10001 x i64], [10001 x i64]* %4, i64 0, i64 %25
%27 = load i64, i64* %26
%28 = add nsw i64 %25, -1
%29 = getelementptr inbounds [10001 x i64], [10001 x i64]* %4, i64 0, i64 %28
%30 = load i64, i64* %29
%31 = add nsw i64 %30, %27
%32 = and i64 %31, 1
%33 = icmp eq i64 %32, 0
%34 = icmp sgt i64 %25, 0
%35 = select i1 %33, i1 %34, i1 false
%36 = add nsw i64 %25, -2
br i1 %35, label %24, label %15
37: ; preds = %15, %2
%38 = phi i64 [ -1, %2 ], [ %25, %15 ]
%39 = add nsw i64 %38, 1
%40 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %39)
ret i32 0
}