#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, i, ar[1005];
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    scanf("%d", &ar[i]);
  if (ar[n - 1] == 0) {
    printf("UP");
    return 0;
  }
  if (ar[n - 1] == 15) {
    printf("DOWN");
    return 0;
  }
  if (n == 1) {
    printf("-1");
    return 0;
  }
  if (ar[n - 1] - ar[n - 2] < 0)
    printf("DOWN");
  else
    printf("UP");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1181 <main+0x61>
movslq -0xc(%rbp),%rax
lea    -0xfc0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe92(%rip),%rdi
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1149 <main+0x29>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
cmpl   $0x0,-0xfc0(%rbp,%rax,4)
jne    11af <main+0x8f>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    124b <main+0x12b>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
cmpl   $0xf,-0xfc0(%rbp,%rax,4)
0f
jne    11dd <main+0xbd>
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    124b <main+0x12b>
cmpl   $0x1,-0x8(%rbp)
jne    11ff <main+0xdf>
lea    0xe1d(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    124b <main+0x12b>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0xfc0(%rbp,%rax,4),%eax
mov    -0x8(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
sub    -0xfc0(%rbp,%rcx,4),%eax
cmp    $0x0,%eax
jge    1238 <main+0x118>
lea    0xdd8(%rip),%rdi
call   1030 <printf@plt>
jmp    1244 <main+0x124>
lea    0xdc4(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xfc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xfd0,%rsp
lea    0xecd(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    117d <main+0x5d>
lea    0x10(%rsp),%r15
xor    %ebx,%ebx
lea    0xead(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
add    $0x4,%r15
cmp    %rax,%rbx
jl     1160 <main+0x40>
movslq %eax,%rcx
mov    0xc(%rsp,%rcx,4),%edx
test   %edx,%edx
je     1196 <main+0x76>
cmp    $0xf,%edx
jne    119f <main+0x7f>
lea    0xe72(%rip),%rdi
jmp    11c3 <main+0xa3>
lea    0xe66(%rip),%rdi
jmp    11c3 <main+0xa3>
cmp    $0x1,%eax
jne    11ad <main+0x8d>
lea    0xe60(%rip),%rdi
jmp    11c3 <main+0xa3>
cmp    0x8(%rsp,%rcx,4),%edx
lea    0xe4e(%rip),%rax
lea    0xe44(%rip),%rdi
cmovl  %rax,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xfd0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

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