1
//
2575 Accepted 220K 0MS C++ 756B PKU
2
3 #include < iostream >
4
5 using namespace std ;
6
7 const int size = 3100 ;
8
9 int data[size] ;
10 int used[size] ;
11
12 int inn ;
13
14 int main()
15 {
16 while ( scanf( " %d " , & inn ) != EOF )
17 {
18 memset( used, 0 , sizeof (used) ) ;
19 bool OK = true ;
20
21 for ( int i = 1 ; i <= inn; i ++ )
22 {
23 scanf( " %d " , & data[i] ) ;
24 }
25
26 if ( 1 == inn )
27 {
28 printf( " Jolly\n " ) ; continue ;
29 }
30
31 for ( int i = 2 ; i <= inn; i ++ )
32 {
33 if ( abs(data[i] - data[i - 1 ]) < inn )
34 {
35 used[abs(data[i] - data[i - 1 ])] = 1 ;
36 }
37 else
38 {
39 OK = false ; break ;
40 }
41 }
42
43 for ( int i = 1 ; i < inn; i ++ )
44 {
45 if ( 0 == used[i] )
46 {
47 OK = false ; break ;
48 }
49 }
50
51 if ( OK ) printf( " Jolly\n " ) ;
52 else printf( " Not jolly\n " ) ;
53
54 }
55 return 0 ;
56 }
2
3 #include < iostream >
4
5 using namespace std ;
6
7 const int size = 3100 ;
8
9 int data[size] ;
10 int used[size] ;
11
12 int inn ;
13
14 int main()
15 {
16 while ( scanf( " %d " , & inn ) != EOF )
17 {
18 memset( used, 0 , sizeof (used) ) ;
19 bool OK = true ;
20
21 for ( int i = 1 ; i <= inn; i ++ )
22 {
23 scanf( " %d " , & data[i] ) ;
24 }
25
26 if ( 1 == inn )
27 {
28 printf( " Jolly\n " ) ; continue ;
29 }
30
31 for ( int i = 2 ; i <= inn; i ++ )
32 {
33 if ( abs(data[i] - data[i - 1 ]) < inn )
34 {
35 used[abs(data[i] - data[i - 1 ])] = 1 ;
36 }
37 else
38 {
39 OK = false ; break ;
40 }
41 }
42
43 for ( int i = 1 ; i < inn; i ++ )
44 {
45 if ( 0 == used[i] )
46 {
47 OK = false ; break ;
48 }
49 }
50
51 if ( OK ) printf( " Jolly\n " ) ;
52 else printf( " Not jolly\n " ) ;
53
54 }
55 return 0 ;
56 }