#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using ll = long long; using pl = pair; #define vl vector #define vvl vector #define vvvl vector #define vm vector #define vvm vector #define vvvm vector #define vp vector #define vvp vector #define vvvp vector #define vs vector #define vvs vector #define vb vector #define vvb vector #define vvvb vector #define vd vector #define vvd vector #define vvvd vector #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for(ll i = ll(a); i < ll(b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define all(x) std::begin(x), std::end(x) #define make_unique(v) v.erase(unique(all(v)), v.end()); #define sum(...) accumulate(all(__VA_ARGS__), 0LL) #define inf (0x1fffffffffffffffLL) template void input(T&... a){ (cin >> ... >> a); } template istream &operator>>(istream &is, vector &v) { for(auto &x : v) { is >> x; } return is; } template ostream &operator<<(ostream &os, const vector &v) { for(int i = 0; i < (int)v.size(); i++) { if(i != (int)v.size() - 1) os << v[i] << " "; else os << v[i]; } return os; } template auto make_v(T x, int arg, Args... args) { if constexpr(sizeof...(args) == 0) return vector(arg, x); else return vector(arg, make_v(x, args...)); } template auto min(const T &a) { return *min_element(all(a)); } template auto max(const T &a) { return *max_element(all(a)); } template bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; } template bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; } struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup; int main() { ll N, M; cin >> N >> M; vl A(M); cin >> A; auto f = [&](auto self, ll n) -> ll { if(n <= 0) return 0; else if(n == 1) return 1; else if(n % 2 == 1 || n % 4 == 0) return 2 * self(self, n / 2); else return 2 * (1 + self(self, n / 2 - 1)); }; ll ans = 0; rep(i, M - 1){ ans += f(f, A[i + 1] - A[i] - 1); } cout << ans << endl; }