#include <bits/stdc++.h>
#define ll long long
using namespace std;
bool stepen2( unsigned long long n ){

}

int main(){
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
unsigned long long n;
long long k;
cin >> n >> k;
ll d[k+3];
for ( int i = 1; i < k+1; i++ ){
    cin >> d[i];
}
ll f[n+1];
f[1] = 1;
f[2] = 3;
f[3] = 2;
f[4] = 7;
f[5] = 4;
f[6] = 6;
f[12] = 14;
if ( n > 7 && n != 12){
    if ( stepen2(n) == true){
        f[n] = 2*n - 1;
    }
    else{
        f[n] = n-1;
    }
}
for ( int i = 1; i <= k; i++ ){
    cout << f[d[i]] << " ";
}

return 0;
}