RT, 只有10pts
#include <iostream>
#include <cmath>
using namespace std;
long long n, q, tmp, cnt, ans;
long long a[128];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> q;
while(q--){
//cout << n << endl;
tmp = n;
cnt = 0;
while(1){
cnt++;
if(tmp & 1) a[cnt] = 1;
else a[cnt] = 0;
tmp >>= 1;
if(!tmp) break;
} //将n以二进制数组的形式存储
int x;
cin >> x;
if(a[x] == 1) ans += 0;
else{
for(int i = 1; i < x; i++){
if(a[i] == 1){
a[i] = 0;
ans += pow(2,i - 1);
a[i + 1]++;
} // 如果第i位是1 则令加数的第i位为0 并进位
else if(a[i] == 2){
a[i + 1]++;
a[i] = 0;
} // 如果进位后这一位为2,则进位,并使当前位置为0
if(a[x] == 1) break;
}
}
n = 0;
int cnt2 = 1;
while(1){
if(cnt2 == 128) break;
if(a[cnt2] == 1) n += pow(2,cnt2 - 1);
cnt2++;
} //计算出新的n
}
cout << ans << endl;
return 0;
}