#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> n >> m; ll pre, ans = 0; cin >> pre; rep(i,m-1){ ll a; cin >> a; ll x = a-pre-1, k = 1; while((x&1) && x>1) x>>=1, k<<=1; ans += x*k; pre = a; } cout << ans << '\n'; return 0; }