#include #include #include #include using namespace std; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) const i64 INF = 1001001001001001001; void testcase(){ i64 N, M; cin >> N >> M; vector A(M); rep(i,M) cin >> A[i]; i64 ans = 0; rep(i,M-1){ i64 a = A[i+1] - A[i] - 1; i64 t = 1; while(a != 1 && a%2 == 1){ a /= 2; t *= 2; } ans += a * t; } cout << ans << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); testcase(); return 0; }