#include <stdio.h>
#include <stdbool.h>
#define gc getchar_unlocked
#define pc putchar_unlocked
inline int scan(){register int n=0,c=gc();while(c<'0'||c>'9')c=gc();while(c<='9'&&c>='0')n=(n<<1)+(n<<3)+c-'0',c=gc();return n;}
bool c[100001]={0};
int findLongestsequence(int a, int count){
int st=a,i,j;
a++;
if(c[a]==1){return(findLongestsequence(a,++count));}
return count;
}//findLongestsequence
int main(void){
int i=0,j,t,n,st,len,count=1,maxcount=1,maxseq=-1;
len=scan();
j=len;
int a[len];
while(j--){
a[i]=scan();
c[a[i]]=1; //creating hash with value pair same
i++;
}
for(i
=0;i
<len
;i
++){printf("%d ",a
[i
]);} for(i=0;i<len;i++){
count = findLongestsequence(a[i],count);
if(count > maxcount ){
maxcount= count;
maxseq = a[i] ;
}
count=1;
}
//printf("\nSt and Len : %d & %d\n",maxseq,maxcount);
printf("\nMaximum Consequitve string "); while(maxcount
--) printf("%d ",maxseq
++); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRib29sLmg+CiNkZWZpbmUgZ2MgZ2V0Y2hhcl91bmxvY2tlZAojZGVmaW5lIHBjIHB1dGNoYXJfdW5sb2NrZWQKaW5saW5lIGludCBzY2FuKCl7cmVnaXN0ZXIgaW50IG49MCxjPWdjKCk7d2hpbGUoYzwnMCd8fGM+JzknKWM9Z2MoKTt3aGlsZShjPD0nOScmJmM+PScwJyluPShuPDwxKSsobjw8MykrYy0nMCcsYz1nYygpO3JldHVybiBuO30KYm9vbCBjWzEwMDAwMV09ezB9OwoKaW50IGZpbmRMb25nZXN0c2VxdWVuY2UoaW50IGEsIGludCBjb3VudCl7CiAgICBpbnQgc3Q9YSxpLGo7CiAgICBhKys7CiAgICBpZihjW2FdPT0xKXtyZXR1cm4oZmluZExvbmdlc3RzZXF1ZW5jZShhLCsrY291bnQpKTt9CiAgICByZXR1cm4gY291bnQ7Cn0vL2ZpbmRMb25nZXN0c2VxdWVuY2UKCmludCBtYWluKHZva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