#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<(int)(n);i++)
#define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define pb(a) push_back(a)
#define ZERO(a) memset(a,0,sizeof(a))
#define len(a) sizeof(a)
#define ll long long
#define INF 1<<29
using namespace std;

int a[101010];

void solve(){
 int n,k;
 for(;;){
  scanf("%d %d",&n,&k);
  if(n==0) break;
  FOR(i,k) scanf("%d",&a[i]);
  sort(a,a+k);
  int ma=0;
  FOR(i,k){
   if(a[i]==0) continue;
   FORR(j,i+1,k){
    if(!a[0]){
     if(a[j]-a[i]<=j-i+1) ma=max(ma,a[j]-a[i]+1);
     else break;
    }
    else{
     if(a[j]-a[i]==j-i) ma=max(ma,a[j]-a[i]+1);
     else break;
    }
   }
  }
  printf("%d\n",ma);
 }
}

int main(){
 solve();
 return 0;
}