#include "bits/stdc++.h"

using namespace std;

const char en = '\n';
using  ll =          long long;
using ull = unsigned long long;


using Bitset = bitset<100001>;
int n,k;

int main(){
	ios::sync_with_stdio(false);cin.tie();
	while(true){
		cin>>n>>k;
		if(n==0&&k==0) break;

		Bitset b;
		int buf;
		for(int i=0;i<k;i++){
			cin>>buf;
			b.set(buf);
		}
		deque<int> d;
		for(int i=1;i<=n;i++){
			if(!b[i])
				d.push_back(i);
		}
		d.push_front(0);
		d.push_back (n+1);


		int result=0;
		if(b[0]){

			int befA=d.front();	d.pop_front();
			int befB=d.front();	d.pop_front();
			while(!d.empty()){
				buf =d.front();	d.pop_front();
				result=max(result,buf-befA-1);
				befA=befB;
				befB=buf;
			}
			cout<<result<<en;

		}else{

			int before=d.front();	d.pop_front();
			while(!d.empty()){
				buf=d.front();	d.pop_front();
				result=max(result,buf-before-1);
				before=buf;
			}
			cout<<result<<en;

		}
		/*
		while(!d.empty()){
			cout<<d.front()<<en;
			d.pop_front();
		}
		cout<<en;
		*/
	}
	return 0;
}