#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(void) {
  int n, prev, val, upDown, diff;
  scanf("%d", &n);
  if (n < 2) {
    printf("1\n");
    return 0;
  }
  scanf("%d", &prev);
  n--;
  scanf("%d", &val);
  n--;
  upDown = val - prev;
  if (!upDown) {
    printf("0\n");
    return 0;
  }
  prev = val;
  while (n--) {
    scanf("%d", &val);
    diff = val - prev;
    if (!diff || (upDown < 0 && diff < 0) || (upDown > 0 && diff > 0)) {
      printf("0\n");
      return 0;
    }
    prev = val, upDown = diff;
  }
  printf("1\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x2,-0x8(%rbp)
jge    1161 <main+0x41>
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125f <main+0x13f>
lea    0xe98(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
lea    0xe7f(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11be <main+0x9e>
lea    0xe59(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125f <main+0x13f>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     124c <main+0x12c>
lea    0xe21(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1223 <main+0x103>
cmpl   $0x0,-0x14(%rbp)
jge    120f <main+0xef>
cmpl   $0x0,-0x18(%rbp)
jl     1223 <main+0x103>
cmpl   $0x0,-0x14(%rbp)
jle    123b <main+0x11b>
cmpl   $0x0,-0x18(%rbp)
jle    123b <main+0x11b>
lea    0xddc(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125f <main+0x13f>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11c4 <main+0xa4>
lea    0xdb0(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xecd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
lea    0xec1(%rip),%r12
cmpl   $0x2,0x4(%rsp)
jl     11e7 <main+0xc7>
lea    0xeaa(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
addl   $0xffffffff,0x4(%rsp)
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
mov    0x4(%rsp),%ecx
lea    -0x1(%rcx),%edx
mov    %edx,0x4(%rsp)
mov    0xc(%rsp),%esi
mov    %esi,%eax
lea    0xe76(%rip),%rbx
sub    0x8(%rsp),%eax
je     11e4 <main+0xc4>
mov    %esi,0x8(%rsp)
add    $0xfffffffe,%ecx
mov    %ecx,0x4(%rsp)
test   %edx,%edx
je     11e7 <main+0xc7>
lea    0xe57(%rip),%r14
lea    0xc(%rsp),%r15
jmp    11bb <main+0x9b>
mov    %ecx,0x8(%rsp)
subl   $0x1,0x4(%rsp)
jb     11e7 <main+0xc7>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%ecx
mov    %ecx,%eax
sub    0x8(%rsp),%eax
je     11e4 <main+0xc4>
test   %ebp,%ebp
jns    11dc <main+0xbc>
test   %eax,%eax
js     11e4 <main+0xc4>
test   %ebp,%ebp
jle    11b0 <main+0x90>
test   %eax,%eax
jle    11b0 <main+0x90>
mov    %rbx,%r12
mov    %r12,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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