#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n,k;
	int num[100000];
	while(1){
		cin >> n >> k;
		if(!n && !k) break;
		bool flag = false;
		for(int i = 0;i < k;i++) {
			cin >> num[i];
			if(num[i] == 0) flag = true;
		}
		sort(num,num + k);
		int ma = -1,prev,cnt = 1;
		if(!flag){
			prev = num[0];
			for(int i = 1;i < k;i++){
				if(num[i] - prev == 1) {
					cnt++;
					ma = max(ma,cnt);
				}
				else cnt = 1;
				prev = num[i];
			}
		}
		else{
			int pcnt = -1;
			prev = num[1];
			for(int i = 2;i < k;i++){
				if(num[i] - prev == 1){
					cnt++;
					ma = max(cnt + pcnt + 1,ma);
				}
				else if(num[i] - prev == 2){
					pcnt = cnt;
					cnt = 1;
					ma = max(ma,cnt + pcnt + 1);
				}
				else{
					pcnt = -1;
					cnt = 1;
				}
				prev = num[i];
			}
		}
		cout << ma << endl;
	}
	return 0;	
}