#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() {
  int N, a, b, jump, i, j, q;
  scanf("%d", &N);
  int arr[N + 2];
  for (i = 1; i <= N; i++)
    scanf("%d", &arr[i]);
  scanf("%d", &q);
  while (q--) {
    jump = 1;
    scanf("%d%d", &a, &b);
    for (i = a + 1; i < b; i++)
      if (arr[i] > arr[a]) {
        jump = 0;
        break;
      }
    if (jump)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecc(%rip),%rdi
xor    %eax,%eax
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11a9 <main+0x89>
mov    -0x38(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1172 <main+0x52>
lea    0xe52(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x20(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x20(%rbp)
cmp    $0x0,%eax
je     1264 <main+0x144>
movl   $0x1,-0x14(%rbp)
lea    0xe23(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1238 <main+0x118>
mov    -0x38(%rbp),%rcx
movslq -0x18(%rbp),%rax
mov    (%rcx,%rax,4),%eax
movslq -0xc(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jle    1225 <main+0x105>
movl   $0x0,-0x14(%rbp)
jmp    1238 <main+0x118>
jmp    122a <main+0x10a>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11f5 <main+0xd5>
cmpl   $0x0,-0x14(%rbp)
je     1253 <main+0x133>
lea    0xdbc(%rip),%rdi
call   1030 <printf@plt>
jmp    125f <main+0x13f>
lea    0xdb0(%rip),%rdi
call   1030 <printf@plt>
jmp    11bb <main+0x9b>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeca(%rip),%rdi
lea    -0x2c(%rbp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rsp,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x2,%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmpl   $0x0,-0x2c(%rbp)
jle    119e <main+0x7e>
lea    0x4(%rbx),%r15
lea    0xe8f(%rip),%r14
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movslq -0x2c(%rbp),%rax
add    $0x1,%r12
add    $0x4,%r15
cmp    %rax,%r12
jl     1180 <main+0x60>
lea    0xe5d(%rip),%rdi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,-0x30(%rbp)
jae    11cb <main+0xab>
mov    -0x40(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe2e(%rip),%r14
lea    -0x38(%rbp),%r15
lea    -0x34(%rbp),%r13
lea    0xe27(%rip),%r12
jmp    11fe <main+0xde>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12,%rdi
call   1030 <puts@plt>
subl   $0x1,-0x30(%rbp)
jb     11b6 <main+0x96>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
movslq -0x38(%rbp),%rax
movslq -0x34(%rbp),%rcx
lea    0x1(%rax),%rdx
nopw   0x0(%rax,%rax,1)
cmp    %rcx,%rdx
jge    11f0 <main+0xd0>
mov    (%rbx,%rdx,4),%esi
add    $0x1,%rdx
cmp    (%rbx,%rax,4),%esi
jle    1220 <main+0x100>
lea    0xdcd(%rip),%rdi
jmp    11f3 <main+0xd3>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [5 x i8] c"YES\0A\00"
@.str.3 = [4 x i8] c"NO\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
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
store i32 0, i32* %1
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 2
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %9
%16 = alloca i32, i64 %14
store i64 %14, i64* %10
store i32 1, i32* %6
br label %17
17: ; preds = %26, %0
%18 = load i32, i32* %6
%19 = load i32, i32* %2
%20 = icmp sle i32 %18, %19
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load i32, i32* %6
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %16, i64 %23
%25 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %21
%27 = load i32, i32* %6
%28 = add nsw i32 %27, 1
store i32 %28, i32* %6
br label %17
29: ; preds = %17
%30 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
br label %31
31: ; preds = %65, %29
%32 = load i32, i32* %8
%33 = add nsw i32 %32, -1
store i32 %33, i32* %8
%34 = icmp ne i32 %32, 0
br i1 %34, label %35, label %66
35: ; preds = %31
store i32 1, i32* %5
%36 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%37 = load i32, i32* %3
%38 = add nsw i32 %37, 1
store i32 %38, i32* %6
br label %39
39: ; preds = %55, %35
%40 = load i32, i32* %6
%41 = load i32, i32* %4
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %58
43: ; preds = %39
%44 = load i32, i32* %6
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %16, i64 %45
%47 = load i32, i32* %46
%48 = load i32, i32* %3
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %16, i64 %49
%51 = load i32, i32* %50
%52 = icmp sgt i32 %47, %51
br i1 %52, label %53, label %54
53: ; preds = %43
store i32 0, i32* %5
br label %58
54: ; preds = %43
br label %55
55: ; preds = %54
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
store i32 %57, i32* %6
br label %39
58: ; preds = %53, %39
%59 = load i32, i32* %5
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %63
61: ; preds = %58
%62 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %65
63: ; preds = %58
%64 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %65
65: ; preds = %63, %61
br label %31
66: ; preds = %31
store i32 0, i32* %1
%67 = load i8*, i8** %9
%68 = load i32, i32* %1
ret i32 %68
}

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