#include #include using namespace atcoder; using namespace std; using ll=long long; using ld=long double; ld pie=3.141592653589793; ll mod=1000000007; ll inf=10000; ll dfs(ll now){ if (now%2==0) { return now; } if (now==5) { return 4; }else if (now==1) { return 1; }else if (now==3) { return 2; } return 2*dfs((now-1)/2); } int main(){ ll n,m; cin >> n >> m; vectora(m); for (ll i = 0; i < m; i++) { cin >> a[i]; } ll ans=0; for (ll i = 1; i < m; i++) { ans+=dfs(a[i]-a[i-1]-1); } cout << ans << endl; }