#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 */
scalar_t__ EOF;
int abs(int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
scalar_t__ scanf(char *, int *);
int main() {
  int n;
  while (scanf("%i", &n) != EOF) {
    int sequence[3000];
    memset(sequence, 0, 3000 * sizeof(int));
    int previous = 0;
    int start = false;
    int counter = n - 1;
    for (int i = 0; i < n; i++) {
      int value = 0;
      scanf("%i", &value);
      if (start == false) {
        previous = value;
        start = true;
        continue;
      }
      int difference = abs(value - previous);
      if (difference > 0 && difference < n) {
        if (sequence[difference] == 0) {
          sequence[difference] = 1;
          counter--;
        }
      }
      previous = value;
    }
    if (counter == 0) {
      printf("Jolly\n");
    } else {
      printf("Not jolly\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2f10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    0x2e7f(%rip),%rcx
cmp    (%rcx),%rax
je     12c0 <main+0x180>
lea    -0x2ef0(%rbp),%rdi
xor    %esi,%esi
mov    $0x2ee0,%edx
call   1050 <memset@plt>
movl   $0x0,-0x2ef4(%rbp)
movl   $0x0,-0x2ef8(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x2efc(%rbp)
movl   $0x0,-0x2f00(%rbp)
mov    -0x2f00(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1291 <main+0x151>
movl   $0x0,-0x2f04(%rbp)
lea    0xe31(%rip),%rdi
lea    -0x2f04(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x2ef8(%rbp)
jne    1203 <main+0xc3>
mov    -0x2f04(%rbp),%eax
mov    %eax,-0x2ef4(%rbp)
movl   $0x1,-0x2ef8(%rbp)
jmp    127d <main+0x13d>
mov    -0x2f04(%rbp),%edi
sub    -0x2ef4(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x2f08(%rbp)
cmpl   $0x0,-0x2f08(%rbp)
jle    1271 <main+0x131>
mov    -0x2f08(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1271 <main+0x131>
movslq -0x2f08(%rbp),%rax
cmpl   $0x0,-0x2ef0(%rbp,%rax,4)
jne    126c <main+0x12c>
movslq -0x2f08(%rbp),%rax
movl   $0x1,-0x2ef0(%rbp,%rax,4)
mov    -0x2efc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x2efc(%rbp)
jmp    1271 <main+0x131>
mov    -0x2f04(%rbp),%eax
mov    %eax,-0x2ef4(%rbp)
mov    -0x2f00(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2f00(%rbp)
jmp    11af <main+0x6f>
cmpl   $0x0,-0x2efc(%rbp)
jne    12af <main+0x16f>
lea    0xd5e(%rip),%rdi
call   1040 <printf@plt>
jmp    12bb <main+0x17b>
lea    0xd54(%rip),%rdi
call   1040 <printf@plt>
jmp    1152 <main+0x12>
xor    %eax,%eax
add    $0x2f10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2ef8,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%rax
jne    1172 <main+0x42>
xor    %eax,%eax
add    $0x2ef8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe87(%rip),%rbx
lea    0x8(%rsp),%r15
lea    0xc(%rsp),%r12
jmp    11be <main+0x8e>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe76(%rip),%rdi
test   %ebp,%ebp
je     11a2 <main+0x72>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x2e2f(%rip),%rcx
cmp    (%rcx),%rax
je     115e <main+0x2e>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x2ee0,%edx
call   1040 <memset@plt>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
jle    119b <main+0x6b>
add    $0xffffffff,%ebp
movl   $0x0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
cmpl   $0x2,0xc(%rsp)
jl     1190 <main+0x60>
mov    0x8(%rsp),%eax
mov    $0x1,%r14d
jmp    1209 <main+0xd9>
add    $0x1,%r14d
cmp    %ecx,%r14d
jge    1190 <main+0x60>
mov    %eax,%r13d
movl   $0x0,0x8(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%eax
mov    %eax,%ecx
sub    %r13d,%ecx
mov    %ecx,%edx
neg    %edx
cmovs  %ecx,%edx
mov    0xc(%rsp),%ecx
jae    1200 <main+0xd0>
cmp    %ecx,%edx
jge    1200 <main+0xd0>
mov    %edx,%edx
cmpl   $0x0,0x10(%rsp,%rdx,4)
jne    1200 <main+0xd0>
movl   $0x1,0x10(%rsp,%rdx,4)
add    $0xffffffff,%ebp
jmp    1200 <main+0xd0>

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

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