#include<iostream>
#include<algorithm>
using namespace std;
int a[100000];
int main() {
	int n, k;
	while (cin >> n >> k&&n != 0 && k != 0) {
		int sum = 1, c = 0;
		fill(a, a + n, false);
		for (int i = 0; i < k; i++) {
			cin >> sum;
			if (sum == 0)
				c++;
			else a[i - c] = sum;
		}
		sum = 0;
		sort(a, a + k - c);
		for (int i = 0; i < k - c; i++) {
			int b = c, ne = a[i], e = i + 1;
			ne++;
			while (ne == a[e]) {
				e++;
				ne++;
			}
			if (c == 1) {
				ne++;
				while (ne == a[e]) {
					ne++;
					e++;
				}
			}
			sum = max(sum, ne - a[i]);
		}
		cout << sum << endl;
	}
}