#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
ios::sync_with_stdio(false) ;
cin.tie(0) ;
cout.tie(0) ;
// int t;
// cin>>t;
// while(t--)
{
int i,n,k;
cin>>n>>k;
vector<int> fa(100006,1e9),la(100006,0);
for(i=1;i<=k;i++)
{
int x;
cin>>x;
fa[x]=min(fa[x],i);
la[x]=max(la[x],i);
}
int na=0;
for(i=1;i<=n;i++)
{
if(fa[i]!=0&&la[i]!=0)
{
na++;
}
else
{
continue;
}
if(i==1)
{
if(la[2]>fa[1])
{
na++;
}
continue;
}
if(i==n)
{
if(la[n-1]>fa[n])
{
na++;
}
continue;
}
if(la[i-1]>fa[i])
{
na++;
}
if(la[i+1]>fa[i])
{
na++;
}
}
cout<<3*n-2-na;
}
return 0;
}
1506D - Epic Transformation | 1354G - Find a Gift |
1426F - Number of Subsequences | 1146B - Hate "A" |
1718C - Tonya and Burenka-179 | 834A - The Useless Toy |
1407D - Discrete Centrifugal Jumps | 1095B - Array Stabilization |
291B - Command Line Arguments | 1174B - Ehab Is an Odd Person |
624B - Making a String | 1064C - Oh Those Palindromes |
1471A - Strange Partition | 1746A - Maxmina |
1746B - Rebellion | 66C - Petya and File System |
1746C - Permutation Operations | 1199B - Water Lily |
570B - Simple Game | 599C - Day at the Beach |
862A - Mahmoud and Ehab and the MEX | 1525A - Potion-making |
1744D - Divisibility by 2n | 1744C - Traffic Light |
1744A - Number Replacement | 1744B - Even-Odd Increments |
637B - Chat Order | 546C - Soldier and Cards |
18D - Seller Bob | 842B - Gleb And Pizza |