#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); ll 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; map M; M[1]=1; auto f=[&](auto f,ll x)->ll{ if(M.count(x)) return M[x]; if(x%2==0) return M[x]=x; return M[x]=2*f(f,x/2); }; ll ans=0; rep(i,m-1) ans+=f(f,B[i]); cout<