#include<stdio.h>
#include <stdlib.h>
int main(){
int i,a[3002],chk[3002],f,n,min,pdiff,ldiff,se,in;
while(scanf("%d",&n)!=EOF){
f=1;
min=99999;
for(i=0;i<=n;i++)
chk[i]=0;
scanf("%d",&a[0]);
for(i=1;i<n;i++){
scanf("%d",&a[i]);
in=abs(a[i]-a[i-1]);
if(chk[in]||in>=n) f=0;
else chk[in]=1;
if(in<min)min=in;
}
for(i=min+1,se=0;i<n && f;i++){
if(chk[i]){
pdiff=i-min;
min=i;
if(se) {
if (pdiff!=ldiff) f=0;
ldiff=pdiff;
se=1;
}
}
}
if(f)printf("Jolly\n");
else printf("Not jolly\n");
}
return 0;
}
No comments:
Post a Comment