int main() {
  int *BIT, *a, i, n;
  scanf("%d", &n);
  BIT = (int *)malloc((n + 1) * sizeof(int));
  memset(BIT, 0, (n + 1) * sizeof(int));
  a = (int *)malloc((n + 1) * sizeof(int));
  for (i = 1; i <= n; i++) {
    printf("c");
    scanf("%d", &a[i]);
    update(i, a[i], BIT, n);
  }
  int x, y;
  scanf("%d", &x), scanf("%d", &y);
  printf("%d\n", query(y, BIT) - query(x - 1, BIT));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdi
shl    $0x2,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdx
shl    $0x2,%rdx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rdi
shl    $0x2,%rdi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     122d <main+0xcd>
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%ecx
mov    $0x0,%al
call   1030 <update@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11cc <main+0x6c>
lea    0xdcc(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    0xdba(%rip),%rdi
lea    -0x28(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x28(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <query@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
sub    $0x1,%edi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <query@plt>
mov    -0x2c(%rbp),%esi
sub    %eax,%esi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xe7c(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
movslq 0x4(%rsp),%rbx
lea    0x4(,%rbx,4),%r15
mov    $0x1,%r13d
mov    $0x1,%edi
mov    %r15,%rsi
call   1060 <calloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1080 <malloc@plt>
test   %rbx,%rbx
jle    1212 <main+0xa2>
mov    %rax,%r15
mov    $0x4,%ebx
lea    0xe31(%rip),%r12
nop
mov    $0x63,%edi
call   1040 <putchar@plt>
lea    (%r15,%rbx,1),%rsi
mov    %r12,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    (%r15,%r13,4),%esi
mov    0x4(%rsp),%ecx
mov    %r13d,%edi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <update@plt>
lea    0x1(%r13),%rax
movslq 0x4(%rsp),%rcx
add    $0x4,%rbx
cmp    %rcx,%r13
mov    %rax,%r13
jl     11d0 <main+0x60>
lea    0xde7(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x8(%rsp),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <query@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
add    $0xffffffff,%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <query@plt>
sub    %eax,%ebx
lea    0xda2(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = call i32 (i8*, ...) @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
%8 = sext i32 %7 to i64
%9 = shl nsw i64 %8, 2
%10 = call i8* @calloc(i64 1, i64 %9)
%11 = bitcast i8* %10 to i32*
%12 = call i8* @malloc(i64 %9)
%13 = bitcast i8* %12 to i32*
%14 = icmp slt i32 %6, 1
br i1 %14, label %28, label %15
15: ; preds = %0, %15
%16 = phi i64 [ %24, %15 ], [ 1, %0 ]
%17 = call i32 @putchar(i32 99)
%18 = getelementptr inbounds i32, i32* %13, i64 %16
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %18)
%20 = load i32, i32* %18
%21 = load i32, i32* %1
%22 = trunc i64 %16 to i32
%23 = call i32 (i32, i32, i32*, i32, ...) bitcast (i32 (...)* @update to i32 (i32, i32, i32*, i32, ...)*)(i32 %22, i32 %20, i32* %11, i32 %21)
%24 = add nuw nsw i64 %16, 1
%25 = load i32, i32* %1
%26 = sext i32 %25 to i64
%27 = icmp slt i64 %16, %26
br i1 %27, label %15, label %28
28: ; preds = %15, %0
%29 = bitcast i32* %2 to i8*
%30 = bitcast i32* %3 to i8*
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%33 = load i32, i32* %3
%34 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @query to i32 (i32, i32*, ...)*)(i32 %33, i32* %11)
%35 = load i32, i32* %2
%36 = add nsw i32 %35, -1
%37 = call i32 (i32, i32*, ...) bitcast (i32 (...)* @query to i32 (i32, i32*, ...)*)(i32 %36, i32* %11)
%38 = sub nsw i32 %34, %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
ret i32 0
}