#include<bits/stdc++.h>
#define P pair<int,int>
using namespace std;
 
signed main(){
int a,b;
int c[100005];
while(scanf("%d%d",&a,&b),a|b){
    for(int d=0;d<b;d++)scanf("%d",&c[d+1]);
    sort(c+1,c+b+1);
    c[0]=c[b+1]=1<<29;
    int MIN=0;
    int s=0;
    vector<P>k;
   for(int x=0;x<b;x++){
       if(c[x+1]==0)continue;
       if(c[x]+1!=c[x+1]&&c[x+1]+1!=c[x+2]){if(s==0)s=1;k.push_back(P(c[x+1],c[x+1]));}
       else if(c[x+1]+1!=c[x+2]){s=max(s,c[x+1]-MIN+1);k.push_back(P(MIN,c[x]+1));}
       else if(c[x]+1!=c[x+1])MIN=c[x+1];
       }
       if(c[1]!=0)printf("%d\n",s);
       else {
	   int qq=0;
	   for(auto o=k.begin(),t=++k.begin();o!=--k.end();o++,t++){
	       if(o->second+2==t->first)qq=max(qq,t->second-o->first+1);
	       }
	       printf("%d\n",qq);
	   }
    }
}