#include<iostream>
#include<map>
#include<cstdio>
using namespace std;
map<int,int>maps;
long long a[1000100],b[1000100];
long long n,m,x,ans;
int main(){
scanf("%lld %lld",&n,&m);
while(m--){
scanf("%lld",&x);
if(x-2>0) maps[x-2] = 1;
if(x-1>0)maps[x-1] = 1;
maps[x] = 1;
if(x+1<=n)maps[x+1] = 1;
if(x+2<=n)maps[x+2] = 1;
}
for(int i=1;i<=n;i++){
if(maps[i] == 1)
ans++;
}
printf("%lld",ans);
return 0;
}
这题是不能用map嘛?