#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,m; cin>>n>>m; vector A(m); rep(i,m) cin>>A[i]; vector B(m-1); rep(i,m-1) B[i]=A[i+1]-A[i]-1; ll ans=0; rep(i,m-1){ if(B[i]==1 || B[i]%2==0) ans+=B[i]; else if(B[i]%4==1) ans+=B[i]-1; else ans+=B[i]/2+1; } cout<