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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xea3(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,%ecx
mov    %rsp,%rax
mov    %rax,-0x18(%rbp)
lea    0xf(,%rcx,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x28(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x20(%rbp)
movl   $0x0,(%rax)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    1204 <main+0xc4>
mov    -0x28(%rbp),%rsi
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe3a(%rip),%rdi
call   1050 <scanf@plt>
mov    -0x28(%rbp),%rcx
movslq -0x8(%rbp),%rax
mov    (%rcx,%rax,4),%eax
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
cmp    (%rcx,%rdx,4),%eax
jge    11f1 <main+0xb1>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f6 <main+0xb6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119f <main+0x5f>
cmpl   $0x0,-0x10(%rbp)
jne    121f <main+0xdf>
lea    0xdee(%rip),%rdi
call   1040 <printf@plt>
jmp    1264 <main+0x124>
cmpl   $0x1,-0x10(%rbp)
je     1233 <main+0xf3>
cmpl   $0x2,-0x10(%rbp)
jne    1244 <main+0x104>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1060 <swap@plt>
jmp    125f <main+0x11f>
cmpl   $0x2,-0x10(%rbp)
jle    125a <main+0x11a>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <reverse@plt>
jmp    125f <main+0x11f>
jmp    1264 <main+0x124>
movl   $0x0,-0x4(%rbp)
mov    -0x18(%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    0xea8(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1050 <scanf@plt>
mov    %rsp,%rbx
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %rsp,%rcx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rcx,%r12
sub    %rax,%r12
mov    %r12,%rsp
neg    %rax
movl   $0x0,(%rcx,%rax,1)
cmpl   $0x0,-0x2c(%rbp)
jle    11fb <main+0xbb>
mov    %rbx,-0x38(%rbp)
xor    %ebx,%ebx
mov    $0x4,%r15d
lea    0xe5b(%rip),%r14
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
lea    (%r12,%r15,1),%rsi
mov    %r14,%rdi
call   1050 <scanf@plt>
mov    0x4(%r12,%rbx,4),%eax
xor    %ecx,%ecx
cmp    (%r12,%rbx,4),%eax
setl   %cl
add    %ecx,%r13d
movslq -0x2c(%rbp),%rsi
add    $0x1,%rbx
add    $0x4,%r15
cmp    %rsi,%rbx
jl     11b0 <main+0x70>
test   %r13d,%r13d
mov    -0x38(%rbp),%rbx
je     11fb <main+0xbb>
add    $0xffffffff,%r13d
mov    %r12,%rdi
cmp    $0x1,%r13d
ja     1209 <main+0xc9>
call   1060 <swap@plt>
jmp    120e <main+0xce>
lea    0xe01(%rip),%rdi
call   1040 <printf@plt>
jmp    120e <main+0xce>
call   1030 <reverse@plt>
mov    %rbx,%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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