#include #include using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define FAST_IO \ ios::sync_with_stdio(false); \ cin.tie(0); const i64 INF = 1001001001001001001; using Modint = atcoder::static_modint<998244353>; i64 f(i64 x) { i64 ret = 0; if (x % 2 == 0) { return x; } else { if (x == 1) return 1; return f((x - 1) / 2) * 2; } } int main() { FAST_IO i64 n; int m; cin >> n >> m; vector a(m, 0LL); for (auto i : views::iota(0, m)) { cin >> a[i]; } auto ans = 0LL; for (auto i : views::iota(0, m - 1)) { auto d = a[i + 1] - a[i] - 1; ans += f(d); } cout << ans << endl; }