Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
 
int main(void){
    while(1){
        int n, k, ans = 0;
        cin >> n >> k;
        if(n == 0 && k == 0) break;//00???????????????????????????
        bool flag = false;//?????¨???????????????0??????????????????????????????????????°
        vector<bool> num(n + 1, false);//?????±??????????????????????????????
        rep(i, k){
            int tmp; scanf("%d", &tmp);
            if(tmp == 0){
                flag = true;
                continue;
            }
            num[tmp] = true;//?????±????????????
        }
        int pre = 0;//???????????£?¶??¢????????????°???????????°?????\????????????
        int cnt = 0;//?????????????????£?¶??¢????????????°???????????°????????????????????????????????¨
        int now;
        int end = 0;//???????????£?¶???¨????¢?????????????????????°????????\????????????
        bool rennketukanouseiflag = false;//??£??\????????£?¶??¢????????????????1?????¨?????????true
        reps(i, 1, n + 1){
            //??°???i????????????
            if(num[i] == true){
                if(i == end + 2) rennketukanouseiflag = true;//???????????£?¶??¢?????????¨?????????1
                cnt++;
            //??°???i???????????¨???
            }else{
                now = cnt;//?????¨??????????????£?¶???¨????¢????????????°???????????°
                //?????¨?????????0????????????????????????????????£??\????????£?¶???¨??????????????°???1???????????¨?????????????????£?¶???¨???????????????????????£????????????
                if(flag == true???&& rennketukanouseiflag == true){
                    ans = max(ans, pre + now + 1);
                }
                //???????????¶????????????????????¨?????????????????£?¶???¨????¢???????????????§?????§??????????????¢?????°??????
                else{
                    ans = max(ans, now);
                }
                    
                // ?????????
                cnt = 0;
                rennketukanouseiflag = false;
                pre = now;//?????¢??£?????????
                end = i;
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:33: error: expected primary-expression before '?' token
   40 |                 if(flag == true???&& rennketukanouseiflag == true){
      |                                 ^
a.cc:40:34: error: expected primary-expression before '?' token
   40 |                 if(flag == true???&& rennketukanouseiflag == true){
      |                                  ^
a.cc:40:59: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   40 |                 if(flag == true???&& rennketukanouseiflag == true){
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
a.cc:40:66: error: expected ':' before ')' token
   40 |                 if(flag == true???&& rennketukanouseiflag == true){
      |                                                                  ^
      |                                                                  :
a.cc:40:66: error: expected primary-expression before ')' token
a.cc:40:66: error: expected ':' before ')' token
   40 |                 if(flag == true???&& rennketukanouseiflag == true){
      |                                                                  ^
      |                                                                  :
a.cc:40:66: error: expected primary-expression before ')' token
a.cc:40:66: error: expected ':' before ')' token
   40 |                 if(flag == true???&& rennketukanouseiflag == true){
      |                                                                  ^
      |                                                                  :
a.cc:40:66: error: expected primary-expression before ')' token
a.cc:40:38: error: label 'rennketukanouseiflag' used but not defined
   40 |                 if(flag == true???&& rennketukanouseiflag == true){
      |                                      ^~~~~~~~~~~~~~~~~~~~