#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main() {
	ll n;
	int q;
	scanf("%I64d %d", &n, &q);
	while (q--) {
		ll k;
		scanf(" %d", &k);
		--k;
		if (k%2 == 0)
			cout << k/2+1 << '\n';
		else {
			ll i = k/2;
			ll m = (n-i-1);
			k += m;
			while (m%2 == 0) {
				m >>= 1;
				k += m;
			}
			cout << k/2+1 << '\n';
		}
	}
}


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)

using namespace std;

const ll INF=(1ll<<62)-1;
const int inf=(1<<30)-1;
ll n;

ll res(ll p)
{
    if(p&1)return (p+1)/2;
    return res(n+(p+1)/2);
}
    int main()
    {
        ios;
        ll q;
        cin>>n>>q;
        int x;

        while(q--)
        {
            cin>>x;
            cout<<res(x)<<endl;
        }

    }


#include<bits/stdc++.h>
#define ll long long
#define ios ios_base::sync_with_stdio(false)

using namespace std;

const ll INF=(1ll<<62)-1;
const int inf=(1<<30)-1;
ll n;

ll res(ll p)
{
    if(p&1)return (p+1)/2;
    return res(n+(p+1)/2);
}
    int main()
    {
        ios;
        ll q;
        cin>>n>>q;
        ll x;

        while(q--)
        {
            cin>>x;
            cout<<res(x)<<endl;
        }

    }


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,q;
int main(){
	scanf("%lld%d",&n,&q);
	for(int i=0;i<q;i++){
		long long x;
		scanf("%lld",&x);
		while(!(x%2)){
			x=((n<<1LL)+x)>>1LL;
		}
		printf("%lld\n",(x>>1)+1);
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,q;
int main(){
	cin>>n>>q;
	for(int i=0;i<q;i++){
		long long x;
		cin>>x;
		while(!(x%2)){
			x=((n<<1LL)+x)>>1LL;
		}
		printf("%lld\n",(x>>1)+1);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,q,x;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=q;i++)
    {
        scanf("%d",&x);
        int num;
        if(x&1)
            num=(x+1)/2;
        else {
                while(x%2==0)
                x+=(n-x/2);
            num=(x+1)/2;
        }
        printf("%d\n",num);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,q,x;
    scanf("%d%d",&n,&q);
    for(int i=1;i<=q;i++)
    {
        scanf("%d",&x);
        long long num;
        if(x&1)
            num=(x+1)/2;
        else {
                while(x%2==0)
                x+=(n-x/2);
            num=(x+1)/2;
        }
        printf("%I64d\n",num);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,x;
    int q;
    scanf("%I64d%d",&n,&q);
    for(int i=1;i<=q;i++)
    {
        scanf("%I64d",&x);
        long long num;
        if(x&1)
            num=(x+1)/2;
        else {
                while(x%2==0)
                x+=(n-x/2);
            num=(x+1)/2;
        }
        printf("%I64d\n",num);
    }
    return 0;
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <string>
#include <unordered_set>

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define files freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define pb push_back
#define all(v) v.begin(), v.end()
#define v_ll vector <long long>
#define v_b vector <bool>
#define v_c vector <char>
#define v_s vector <string>
#define v_p vector < pair <long long, long long> >
#define FIXED cout << fixed << setprecision(10) <<
#define str string
#define getl getline
#define res resize
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define ll long long
#define ld long double
#define rep(i, l, r) for (long long i = l; i < r; i++)
#define per(i, r, l) for (long long i = r; i >= l; i--)

using namespace std;

void print_v(v_ll v)
{
	for (auto i : v) {
		cout << i << " ";
	}
}

signed main()
{
	FAST;
	ll n, q;
	cin >> n >> q;
	rep(i, 0, q) {
		ll a; cin >> a;
		while (a % 2 == 0) {
			a += n - a / 2;
		}
		cout << (a + 1) / 2 << '\n';
	}
	system("pause");
}


#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <string>
#include <unordered_set>

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define files freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define pb push_back
#define all(v) v.begin(), v.end()
#define v_ll vector <long long>
#define v_b vector <bool>
#define v_c vector <char>
#define v_s vector <string>
#define v_p vector < pair <long long, long long> >
#define FIXED cout << fixed << setprecision(10) <<
#define str string
#define getl getline
#define res resize
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define ll long long
#define ld long double
#define rep(i, l, r) for (long long i = l; i < r; i++)
#define per(i, r, l) for (long long i = r; i >= l; i--)

using namespace std;

void print_v(v_ll v)
{
	for (auto i : v) {
		cout << i << " ";
	}
}

signed main()
{
	FAST;
	ll n, q;
	cin >> n >> q;
	rep(i, 0, q) {
		ll a; cin >> a;
		while (a % 2 == 0) {
			a += n - a / 2;
		}
		cout << (a + 1) / 2 << '\n';
	}
	//system("pause");
}


//
//  main.cpp
//   вансин
//
//  Created by Линь Вансин on 27.02.18.
//  Copyright © 2018 Линь Вансин. All rights reserved.
//
#include <iostream>
#include <string.h>
using namespace std;
int main() {
    long long a,b;
    cin>>a>>b;
    long long m[b];
    for(long long i=0;i<b;i++)
    {cin>>m[i];}
    long long k=(a*2-1);
    long long l;
    long long otv;
    for(long long i=0;i<b;i++)
    {if(m[i]%2==1)
    {otv=(m[i]+1)/2;
        cout<<otv<<"\n";}
    else {l=k-m[i];
        while(l%2==1)
        {
           l=(l-1)/2;

        }

        cout<<((k-l)+1)/2<<endl;
    }}

}


//
//  main.cpp
//   вансин
//
//  Created by Линь Вансин on 27.02.18.
//  Copyright © 2018 Линь Вансин. All rights reserved.
//
#include <iostream>
#include <string.h>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    int m[b];
    for(int i=0;i<b;i++)
    {cin>>m[i];}
    int k=(a*2-1);
    int l;
    int otv;
    for(int i=0;i<b;i++)
    {if(m[i]%2==1)
    {otv=(m[i]+1)/2;
        cout<<otv<<"\n";}
    else {l=k-m[i];
        while(l%2==1)
        {
           l=(l-1)/2;

        }

        cout<<((k-l)+1)/2<<endl;
    }}

}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
typedef unsigned long long ull;

ull n,q;

ull f(ull pos){
    if(pos%2){
        return (pos+1)/2;
    }
    ull p=n-pos/2;
    return f(pos+p);
}
int main(){
    cin>>n>>q;
    ull x;
    for(int i=1;i<=q;i++){
        cin>>x;
        if(x%2)
            cout<<(x+1)/2<<endl;
        else{
            cout<<f(x)<<endl;
        }
    }

return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
long long n;
int q;
int a[100];
int f(long long pos){
    if(pos%2){
        return (pos+1)/2;
    }
    long long p=n-pos/2;
    return f(pos+p);
}
int main(){
    cin>>n>>q;
    long long x;
    for(int i=1;i<=q;i++){
        cin>>x;
        if(x%2)
            cout<<(x+1)/2<<endl;
        else{
            cout<<f(x)<<endl;
        }
    }

return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
typedef unsigned long long ull;

ull n,q;

ull f(ull pos){
    if(pos%2){
        return (pos+1)/2;
    }
    ull p=n-pos/2;
    return f(pos+p);
}
int main(){
    cin>>n>>q;
    ull x;
    for(int i=1;i<=q;i++){
        cin>>x;
        cout<<f(x)<<endl;
    }
return 0;
}


#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
typedef unsigned long long ull;

ull n;
int q;
int f(ull pos){
    if(pos%2){
        return (pos+1)/2;
    }
    ull p=n-pos/2;
    return f(pos+p);
}
int main(){
    cin>>n>>q;
    ull x;
    for(int i=1;i<=q;i++){
        cin>>x;
        if(x%2)
            cout<<(x+1)/2<<endl;
        else{
            cout<<f(x)<<endl;
        }
    }

return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int find(ll l, ll r, ll idx) {
    if(idx % 2) return idx;
    ll lt = l + (l % 2), rt = r - (r % 2), total = (r - l) / 2 + 1;
    ll a = (idx - lt) / 2, b = (rt - idx) / 2;
    return find(r + 1, r + total, r + 1 + a);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, q, t;
    cin >> n >> q;
    while(q--) {
        cin >> t;
        cout << (find(1LL, n, t) + 1) / 2 << '\n';
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int find(ll l, ll r, ll idx) {
    if(r == l + 1 && idx == r)     return r + 1;
    if(idx % 2) return idx;
    ll lt = l + (l % 2), rt = r - (r % 2), total = (rt - lt) / 2 + 1;
    ll a = (idx - lt) / 2, b = (rt - idx) / 2;
    return find(r + 1, r + total, r + 1 + a);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, q, t;
    cin >> n >> q;
    while(q--) {
        cin >> t;
        cout << (find(1LL, n, t) + 1) / 2 << '\n';
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
ll find(ll l, ll r, ll idx) {
    if(idx % 2) return idx;
    ll lt = l + (l % 2), rt = r - (r % 2), total = (rt - lt) / 2 + 1;
    ll a = (idx - lt) / 2, b = (rt - idx) / 2;
    return find(r + 1, r + total, r + 1 + a);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, q, t;
    cin >> n >> q;
    while(q--) {
        cin >> t;
        cout << (find(1LL, n, t) + 1) / 2 << '\n';
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int find(ll l, ll r, ll idx) {
    if(idx % 2) return idx;
    ll lt = l + (l % 2), rt = r - (r % 2), total = (rt - lt) / 2 + 1;
    ll a = (idx - lt) / 2, b = (rt - idx) / 2;
    return find(r + 1, r + total, r + 1 + a);
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, q, t;
    cin >> n >> q;
    while(q--) {
        cin >> t;
        cout << (find(1LL, n, t) + 1) / 2 << '\n';
    }
    return 0;
}


// Author   : tik-tok
// Language : C++
// ********************
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <cmath>
#include <bitset>
#include <string>
#include <regex>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define readFile  freopen("in.txt","r",stdin)
#define writeFile freopen("out.txt","w",stdout)
#define fastIO ios::sync_with_stdio(0)

int main() {
	fastIO;
	#ifndef ONLINE_JUDGE
		readFile;
		//writeFile;
	#endif;

		ll n, q;
		cin >> n >> q;
		while (q--) {
			ll p;	cin >> p;
			if (p % 2 == 1) {
				cout << (p + 1) / ll(2) << endl;
			}
			else {
				ll last_jump = p + (n - p) + (p / ll(2) - 1) + 1 - p;
				while (last_jump % ll(2) == 0) {
					p += last_jump;
					last_jump /= ll(2);
				}
				p += last_jump;
				cout << (p + 1) / ll(2) << endl;
			}
		}

	return 0;
}


// Author   : tik-tok
// Language : C++
// ********************
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <cmath>
#include <bitset>
#include <string>
#include <regex>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define readFile  freopen("in.txt","r",stdin)
#define writeFile freopen("out.txt","w",stdout)
#define fastIO ios::sync_with_stdio(0)

int main() {
	fastIO;
	#ifndef ONLINE_JUDGE
		readFile;
		//writeFile;
	#endif;

		int n, q;
		cin >> n >> q;
		while (q--) {
			int p;	cin >> p;
			if (p % 2 == 1) {
				cout << (p + 1) / 2 << endl;
			}
			else {
				int last_jump = p + (n - p) + (p / 2 - 1) + 1 - p;
				while (last_jump % 2 == 0) {
					p += last_jump;
					last_jump /= 2;
				}
				p += last_jump;
				cout << (p + 1) / 2 << endl;
			}
		}

	return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	long long int n,q;
	cin>>n>>q;
	while(q--){
		long long int t;scanf("%lld",&t);
		if(t%2==1) printf("%lld\n",t/2+1);
		else{
			while(t%2==0){
				t=t+(n-t/2);
			}
			printf("%lld\n",t/2+1);
		}
	}
}


#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,q;
	cin>>n>>q;
	while(q--){
		int t;scanf("%d",&t);
		if(t%2==1) printf("%d\n",t/2+1);
		else{
			while(t%2==0){
				t=t+(n-t/2);
			}
			printf("%d\n",t/2+1);
		}
	}
}


/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
#include <bits/stdc++.h>

using namespace std;

typedef int I;
typedef long long int LL;
typedef double D;
typedef long double LD;

typedef pair<I,I> PII;
typedef pair<LL,LL> PLL;
typedef pair<LL,I> PLI;
typedef pair<D,I> PDI;

typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDI> VPDI;

typedef set<I> SI;
typedef set<PII> SPI;
typedef set<PLL> SPL;
typedef set<LL> SLL;

#define endl '\n'
#define ifor(i,st,ed) for(int i = (st); i<=(ed); ++i)
#define dfor(i,st,ed) for(int i = (st); i>=(ed); --i)
#define efor(it,x) for(auto it : x)
#define sz(x) ((I)(x).size())
#define fr first
#define sc second
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define eb(x) emplace_back((x))
#define ins(x) insert((x))
#define all(x) (x).begin(),(x).end()
#define lb(x,e) lower_bound(all(x),e)
#define ub(x,e) upper_bound(all(x),e)
#define srt(x) sort(all(x))
#define rev(x) reverse(all(x))
#define srtn(x,n) sort((x),(x) + (n))
#define revn(x,n) reverse((x),(x) + (n))

I main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
    LL n;cin>>n;I q;cin>>q;
    while(q--)
    {
        LL p;cin>>p;
        LL car = 0ll, aux = n;
        if(!(p&1))
        {
            car += (aux+1)/2;
            aux/=2;p/=2;
            if(n&1)while((p&1)&&p>1)
            {
                car += (aux+1)/2;
                p = (p+1)/2;aux/=2;
            }
            else while((!(p&1)))
            {
                car += (aux+1)/2;
                p = p/2;aux/=2;
            }
            cout << (p+1)/2 + car << endl;
        }
        else cout << (p+1)/2 << endl;
    }

    return 0;
}

/**
                        We can all benefit by doing occasional "toy" programs, when artificial
                        restrictions are set up, so that we are forced to push our abilities to
                        the limit.The art of tackling miniproblems with all our energy will sharpen
                        our talents for the real problems.
                                                        Donald E. Knuth
**/


/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
#include <bits/stdc++.h>

using namespace std;

typedef int I;
typedef long long int LL;
typedef double D;
typedef long double LD;

typedef pair<I,I> PII;
typedef pair<LL,LL> PLL;
typedef pair<LL,I> PLI;
typedef pair<D,I> PDI;

typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDI> VPDI;

typedef set<I> SI;
typedef set<PII> SPI;
typedef set<PLL> SPL;
typedef set<LL> SLL;

#define endl '\n'
#define ifor(i,st,ed) for(int i = (st); i<=(ed); ++i)
#define dfor(i,st,ed) for(int i = (st); i>=(ed); --i)
#define efor(it,x) for(auto it : x)
#define sz(x) ((I)(x).size())
#define fr first
#define sc second
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define eb(x) emplace_back((x))
#define ins(x) insert((x))
#define all(x) (x).begin(),(x).end()
#define lb(x,e) lower_bound(all(x),e)
#define ub(x,e) upper_bound(all(x),e)
#define srt(x) sort(all(x))
#define rev(x) reverse(all(x))
#define srtn(x,n) sort((x),(x) + (n))
#define revn(x,n) reverse((x),(x) + (n))

I main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
    LL n;cin>>n;I q;cin>>q;
    while(q--)
    {
        LL p;cin>>p;
        LL car = 0ll, aux = n, nxt = (n+1)/2;
        bool st = 1,flg = 1;
        while(p>1)
        {
            if(st&&(p&1)){
                cout << (p+1)/2 + car << endl;
                flg = 0;break;
            }
            if((!st)&&(!(p&1))){
                cout << p/2 + car << endl;
                flg = 0;break;
            }
            if(aux&1)
                st^=1;
            car += nxt;
            p = (p+1)/2, aux = (aux+1)/2, nxt = (nxt+1)/2;
        }
        if(flg)cout << (p+1)/2 + car << endl;
    }

    return 0;
}

/**
                        We can all benefit by doing occasional "toy" programs, when artificial
                        restrictions are set up, so that we are forced to push our abilities to
                        the limit.The art of tackling miniproblems with all our energy will sharpen
                        our talents for the real problems.
                                                        Donald E. Knuth
**/


/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/
#include <bits/stdc++.h>

using namespace std;

typedef int I;
typedef long long int LL;
typedef double D;
typedef long double LD;

typedef pair<I,I> PII;
typedef pair<LL,LL> PLL;
typedef pair<LL,I> PLI;
typedef pair<D,I> PDI;

typedef vector<I> VI;
typedef vector<LL> VLL;
typedef vector<D> VD;
typedef vector<LD> VLD;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDI> VPDI;

typedef set<I> SI;
typedef set<PII> SPI;
typedef set<PLL> SPL;
typedef set<LL> SLL;

#define endl '\n'
#define ifor(i,st,ed) for(int i = (st); i<=(ed); ++i)
#define dfor(i,st,ed) for(int i = (st); i>=(ed); --i)
#define efor(it,x) for(auto it : x)
#define sz(x) ((I)(x).size())
#define fr first
#define sc second
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define eb(x) emplace_back((x))
#define ins(x) insert((x))
#define all(x) (x).begin(),(x).end()
#define lb(x,e) lower_bound(all(x),e)
#define ub(x,e) upper_bound(all(x),e)
#define srt(x) sort(all(x))
#define rev(x) reverse(all(x))
#define srtn(x,n) sort((x),(x) + (n))
#define revn(x,n) reverse((x),(x) + (n))

I main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
    LL n;cin>>n;I q;cin>>q;
    while(q--)
    {
        LL p;cin>>p;
        LL car = 0ll, aux = n;
        bool st = 1, flg = 1;
        while(p>=1)
        {
            if(st&&(p&1))
            {
                cout << (p+1)/2 + car << endl;
                flg = 0;break;
            }
            if((!st)&&(!(p&1)))
            {
                cout << p/2 + car << endl;
                flg = 0;break;
            }
            LL tmp = aux;
            car += (st?(aux+1)/2:aux/2);
            aux = (st?aux/2:(aux+1)/2);
            p = (st?p/2:(p+1)/2);
            if(tmp&1)st^=1;
        }
        if(flg)cout << 1+car << endl;
    }

    return 0;
}

/**
                        We can all benefit by doing occasional "toy" programs, when artificial
                        restrictions are set up, so that we are forced to push our abilities to
                        the limit.The art of tackling miniproblems with all our energy will sharpen
                        our talents for the real problems.
                                                        Donald E. Knuth
**/


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cctype>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef unsigned long long LL;
const int inf=65;
int m;LL n,x,delt,t,len,id,now,d,mx,c;
void query()
{
	cin>>x;
	if(x&1)
	  {
		cout<<x/2+1<<endl;
		return;
	  }
	delt=(2*n-x)/2;
	for(int i=1;i<=inf;i++)
	  {
		if((1ll<<i)>delt)
		  {
			t=i-1;
			break;
		  }
	  }
	len=1ll<<t;
	id=2*len-delt;
	if(id==len)
	  {
		cout<<n<<endl;
		return;
	  }
	now=len/2,c=len/2/2,mx=1;
	while(now)
	  {
		if(id==now)
		  {
			cout<<n-mx<<'\n';
			return;
		  }
		if(id>now)
		  {
			now+=c;
			mx=(mx<<1);
		  }
		else
		  {
			now-=c;
			mx=(mx<<1|1);
		  }
		c>>=1;
	  }
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++) query();
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cctype>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define LL long long
using namespace std;
int q;
LL n,m;
void read(int &x)
{
	char ch;
	x=0;
	int F=0;
	ch=getchar();
	while(!isdigit(ch))
	  {
	  	if(ch=='-') F=1;
	  	ch=getchar();
	  }
	while(isdigit(ch))
	  {
	  	x=x*10+ch-'0';
	  	ch=getchar();
	  }
	if(F) x=-x;
	return;
}
void read(LL &x)
{
	char ch;
	x=0;
	int F=0;
	ch=getchar();
	while(!isdigit(ch))
	  {
	  	if(ch=='-') F=1;
	  	ch=getchar();
	  }
	while(isdigit(ch))
	  {
	  	x=x*10+ch-'0';
	  	ch=getchar();
	  }
	if(F) x=-x;
	return;
}
void read(char *s)
{
	char ch;
	ch=getchar();
	while(!isalpha(ch)) ch=getchar();
	int t=0;
	while(isalpha(ch))
	  {
	  	s[t++]=ch;
	  	ch=getchar();
	  }
	s[t]=0;
	return;
}
void write(LL x)
{
	if(!x) putchar('0');
	else
	  {
	  	char s[20];
		int cnt=0,F=0;
		if(x<0) x=-x,F=1;
	  	while(x) s[++cnt]=x%10+'0',x/=10;
	  	if(F) putchar('-');
	  	for(int i=cnt;i>=1;i--) putchar(s[i]);
	  }
	putchar('\n');
	return;
}
void getans(LL n,LL nn,LL m,LL add)
{
	if(n%2)
	  {
	  	if(m%2==0)
		  {
		  	write(add+m/2);
		  	return;
		  }
	  	else
		  {
		  	if(nn%2==1) getans((n+1)/2,nn/2,(m+1)/2,add+(nn+1)/2);
		  	else getans((n+1)/2,nn/2,(m+1)/2,add+nn/2);
		  }
	  }
	else
	  {
	  	if(m%2==1)
		  {
		  	write(add+(m+1)/2);
		  	return;
		  }
	  	else
	  	  {
		  	if(nn%2==1) getans((n+1)/2,nn/2,(m+1)/2,add+(nn+1)/2);
		  	else getans((n+1)/2,nn/2,(m+1)/2,add+nn/2);
		  }
	  }
	return;
}
void solve()
{
	read(n);read(q);
	for(int i=1;i<=q;i++)
	  {
	  	read(m);
	  	if(m%2) write((m+1)/2);
	  	else getans(n,n/2,m/2,(n+1)/2);
	  }
	return;
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	solve();
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cctype>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define LL long long
using namespace std;
int q;
LL n,m;
void read(int &x)
{
	char ch;
	x=0;
	int F=0;
	ch=getchar();
	while(!isdigit(ch))
	  {
	  	if(ch=='-') F=1;
	  	ch=getchar();
	  }
	while(isdigit(ch))
	  {
	  	x=x*10+ch-'0';
	  	ch=getchar();
	  }
	if(F) x=-x;
	return;
}
void read(LL &x)
{
	char ch;
	x=0;
	int F=0;
	ch=getchar();
	while(!isdigit(ch))
	  {
	  	if(ch=='-') F=1;
	  	ch=getchar();
	  }
	while(isdigit(ch))
	  {
	  	x=x*10+ch-'0';
	  	ch=getchar();
	  }
	if(F) x=-x;
	return;
}
void read(char *s)
{
	char ch;
	ch=getchar();
	while(!isalpha(ch)) ch=getchar();
	int t=0;
	while(isalpha(ch))
	  {
	  	s[t++]=ch;
	  	ch=getchar();
	  }
	s[t]=0;
	return;
}
void write(LL x)
{
	if(!x) putchar('0');
	else
	  {
	  	char s[20];
		int cnt=0,F=0;
		if(x<0) x=-x,F=1;
	  	while(x) s[++cnt]=x%10+'0',x/=10;
	  	if(F) putchar('-');
	  	for(int i=cnt;i>=1;i--) putchar(s[i]);
	  }
	putchar('\n');
	return;
}
void getans(LL n,LL nn,LL m,LL add)
{
	if(n%2)
	  {
	  	if(m%2==0)
		  {
		  	write(add+m/2);
		  	return;
		  }
	  	else getans((n+1)/2,nn/2,(m+1)/2,add+nn/2);
	  }
	else
	  {
	  	if(m%2==1)
		  {
		  	write(add+(m+1)/2);
		  	return;
		  }
	  	else getans(n/2,nn/2,m/2,add+(nn+1)/2);
	  }
	return;
}
void solve()
{
	read(n);read(q);
	for(int i=1;i<=q;i++)
	  {
	  	read(m);
	  	if(m%2) write((m+1)/2);
	  	else getans(n,n/2,m/2,(n+1)/2);
	  }
	return;
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	solve();
	return 0;
}


#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cctype>
#include<cstring>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define LL long long
using namespace std;
int q;
LL n,m;
void read(int &x)
{
	char ch;
	x=0;
	int F=0;
	ch=getchar();
	while(!isdigit(ch))
	  {
	  	if(ch=='-') F=1;
	  	ch=getchar();
	  }
	while(isdigit(ch))
	  {
	  	x=x*10+ch-'0';
	  	ch=getchar();
	  }
	if(F) x=-x;
	return;
}
void read(LL &x)
{
	char ch;
	x=0;
	int F=0;
	ch=getchar();
	while(!isdigit(ch))
	  {
	  	if(ch=='-') F=1;
	  	ch=getchar();
	  }
	while(isdigit(ch))
	  {
	  	x=x*10+ch-'0';
	  	ch=getchar();
	  }
	if(F) x=-x;
	return;
}
void read(char *s)
{
	char ch;
	ch=getchar();
	while(!isalpha(ch)) ch=getchar();
	int t=0;
	while(isalpha(ch))
	  {
	  	s[t++]=ch;
	  	ch=getchar();
	  }
	s[t]=0;
	return;
}
void write(LL x)
{
	if(!x) putchar('0');
	else
	  {
	  	char s[20];
		int cnt=0,F=0;
		if(x<0) x=-x,F=1;
	  	while(x) s[++cnt]=x%10+'0',x/=10;
	  	if(F) putchar('-');
	  	for(int i=cnt;i>=1;i--) putchar(s[i]);
	  }
	putchar('\n');
	return;
}
void getans(LL n,LL nn,LL m,LL add)
{
	if(n%2)
	  {
	  	if(m%2==0)
		  {
		  	write(add+m/2);
		  	return;
		  }
	  	else getans((n+1)/2,nn/2,(m+1)/2,add+(nn+1)/2);
	  }
	else
	  {
	  	if(m%2==1)
		  {
		  	write(add+(m+1)/2);
		  	return;
		  }
	  	else getans(n/2,nn/2,m/2,add+nn/2);
	  }
	return;
}
void solve()
{
	read(n);read(q);
	for(int i=1;i<=q;i++)
	  {
	  	read(m);
	  	if(m%2) write((m+1)/2);
	  	else getans(n,n/2,m/2,(n+1)/2);
	  }
	return;
}
int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	solve();
	return 0;
}


#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstring>
#include <stdio.h>

using namespace std;
const int maxn=2e5+10;
vector<int> v[maxn];
char s[maxn];
int a[45];
/*
 memset(a,0,sizeof(a));
    for(int n=1;n<=20;++n){
      printf("%2d: ",n);
      for(int i=1;i<=n;i++){
        a[2*i-1]=i;
      }
    int j=2*n-2,i=2*n-1;
    while(j){
        while(!a[i]) i--;
        a[j]=a[i--];
        j-=2;
    }
        for(int i=1;i<=n;i++){
        printf(" %d",a[i]);
        }
        printf("\n");
    }
*/
int main(){
   int n,q;
   scanf("%d%d",&n,&q);
   while(q--){
    int x;
    scanf("%d",&x);
    if(x%2==1){
        printf("%d\n",x/2+1);
        continue;
    }
    int ans=0;
    int m=n;
    while(x%2==0){
        x=m-x/2;
        m=x;
    }
    printf("%d\n",n-x+(x+1)/2);
   }
    return 0;
}


#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstring>
#include <stdio.h>

using namespace std;
const int maxn=2e5+10;
typedef long long ll;

vector<int> v[maxn];
char s[maxn];
int a[45];
/*
 memset(a,0,sizeof(a));
    for(int n=1;n<=20;++n){
      printf("%2d: ",n);
      for(int i=1;i<=n;i++){
        a[2*i-1]=i;
      }
    int j=2*n-2,i=2*n-1;
    while(j){
        while(!a[i]) i--;
        a[j]=a[i--];
        j-=2;
    }
        for(int i=1;i<=n;i++){
        printf(" %d",a[i]);
        }
        printf("\n");
    }
*/
int main(){
   ll n,q;
   scanf("%I64d%I64d",&n,&q);
   while(q--){
    ll x;
    scanf("%I64d",&x);
    if(x%2==1){
        printf("%I64d\n",x/2+1);
        continue;
    }
    ll m=n;
    while(x%2==0){
        x=m-x/2;
        m=x;
    }
    printf("%I64d\n",n-x+(x+1)/2);
   }
    return 0;
}


#include <vector>
#include <algorithm>
#include <string>
#include <string.h>
#include <cstring>
#include <stdio.h>

using namespace std;
const int maxn=2e5+10;
typedef long long ll;

vector<int> v[maxn];
char s[maxn];
int a[45];
/*
 memset(a,0,sizeof(a));
    for(int n=1;n<=20;++n){
      printf("%2d: ",n);
      for(int i=1;i<=n;i++){
        a[2*i-1]=i;
      }
    int j=2*n-2,i=2*n-1;
    while(j){
        while(!a[i]) i--;
        a[j]=a[i--];
        j-=2;
    }
        for(int i=1;i<=n;i++){
        printf(" %d",a[i]);
        }
        printf("\n");
    }
*/
int main(){
   ll n,q;
   scanf("%I64d%I64d",&n,&q);
   while(q--){
    ll x;
    scanf("%I64d",&x);
    if(x%2==1){
        printf("%I64d\n",x/2+1);
        continue;
    }
    int ans=0;
    int m=n;
    while(x%2==0){
        x=m-x/2;
        m=x;
    }
    printf("%I64d\n",n-x+(x+1)/2);
   }
    return 0;
}


#include <assert.h>

#include <cstring>
#include <cstdio>
#include <list>
#include <bitset>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <complex>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int64;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int > vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#define ALL(x) (x).begin(), (x).end()
#define CLEAR(x) (x).clear()
#define RESET(x) memset((x), 0, sizeof (x))

#define FOR(i, b, e) for ( int i = (b); i < (e); ++i)
#define RE(i, n) FOR(i, 0, (n))
#define FOREACH(i, x, y) for ( int i = (x); i <= (y); ++i)

#define SIZE(X) ((int)(X.size())) //NOTES:SIZE(
#define LENGTH(X) ((int)(X.length())) //NOTES:LENGTH(
#define MP(X,Y) make_pair(X,Y)//NOTES:MP(

typedef long long int64; //NOTES:int64
typedef unsigned long long uint64;//NOTES:uint64
#define two(X) (1<<(X))//NOTES:two(
#define twoL(X) (((int64)(1))<<(X)) //NOTES:twoL(
#define contain(S,X) (((S)&two(X))!=0)//NOTES:contain(
#define containL(S,X) (((S)&twoL(X))!=0)//NOTES:containL(
#define chkmin(X, Y) (X) = min((X), (Y))
#define chkmax(X, Y) (X) = max((X), (Y))
#define sqr(X) ((X) * (X))

const ll maxn = (ll) 2e5 + 100;
const ll maxm = (ll)1e7 + 10000;
const int LOGN = 22;
const ll INF = 1e9 + 10;
const double PI = acos(-1.0);
const ll MOD = 313;
const double EPS = 1e-12;

ll Cal(ll x, ll n) {
    if (x & 1) {
        return x / 2 + 1;
    }
    while ((x & 1) == 0) {
        ll pre = x / 2;
        x = n - pre + x;
    }
    return x / 2 + 1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n, q;
    while (cin >> n >> q) {
        RE(i, q) {
            ll x;
            cin >> x;
            cout << Cal(x, n) << endl;
        }
    }

    return 0;
}


#include <assert.h>

#include <cstring>
#include <cstdio>
#include <list>
#include <bitset>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <complex>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int64;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int > vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#define ALL(x) (x).begin(), (x).end()
#define CLEAR(x) (x).clear()
#define RESET(x) memset((x), 0, sizeof (x))

#define FOR(i, b, e) for ( int i = (b); i < (e); ++i)
#define RE(i, n) FOR(i, 0, (n))
#define FOREACH(i, x, y) for ( int i = (x); i <= (y); ++i)

#define SIZE(X) ((int)(X.size())) //NOTES:SIZE(
#define LENGTH(X) ((int)(X.length())) //NOTES:LENGTH(
#define MP(X,Y) make_pair(X,Y)//NOTES:MP(

typedef long long int64; //NOTES:int64
typedef unsigned long long uint64;//NOTES:uint64
#define two(X) (1<<(X))//NOTES:two(
#define twoL(X) (((int64)(1))<<(X)) //NOTES:twoL(
#define contain(S,X) (((S)&two(X))!=0)//NOTES:contain(
#define containL(S,X) (((S)&twoL(X))!=0)//NOTES:containL(
#define chkmin(X, Y) (X) = min((X), (Y))
#define chkmax(X, Y) (X) = max((X), (Y))
#define sqr(X) ((X) * (X))

const ll maxn = (ll) 2e5 + 100;
const ll maxm = (ll)1e7 + 10000;
const int LOGN = 22;
const ll INF = 1e9 + 10;
const double PI = acos(-1.0);
const ll MOD = 313;
const double EPS = 1e-12;

int Cal(ll x, ll n) {
    if (x & 1) {
        return x / 2 + 1;
    }
    while ((x & 1) == 0) {
        ll pre = x / 2;
        x += n - pre;
    }
    return x / 2 + 1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n, q;
    while (cin >> n >> q) {
        RE(i, q) {
            ll x;
            cin >> x;
            cout << Cal(x, n) << endl;
        }
    }

    return 0;
}


#include <assert.h>

#include <cstring>
#include <cstdio>
#include <list>
#include <bitset>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <ctime>
#include <cmath>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <complex>
#include <functional>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int64;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int > vi;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;

#define ALL(x) (x).begin(), (x).end()
#define CLEAR(x) (x).clear()
#define RESET(x) memset((x), 0, sizeof (x))

#define FOR(i, b, e) for ( int i = (b); i < (e); ++i)
#define RE(i, n) FOR(i, 0, (n))
#define FOREACH(i, x, y) for ( int i = (x); i <= (y); ++i)

#define SIZE(X) ((int)(X.size())) //NOTES:SIZE(
#define LENGTH(X) ((int)(X.length())) //NOTES:LENGTH(
#define MP(X,Y) make_pair(X,Y)//NOTES:MP(

typedef long long int64; //NOTES:int64
typedef unsigned long long uint64;//NOTES:uint64
#define two(X) (1<<(X))//NOTES:two(
#define twoL(X) (((int64)(1))<<(X)) //NOTES:twoL(
#define contain(S,X) (((S)&two(X))!=0)//NOTES:contain(
#define containL(S,X) (((S)&twoL(X))!=0)//NOTES:containL(
#define chkmin(X, Y) (X) = min((X), (Y))
#define chkmax(X, Y) (X) = max((X), (Y))
#define sqr(X) ((X) * (X))

const ll maxn = (ll) 2e5 + 100;
const ll maxm = (ll)1e7 + 10000;
const int LOGN = 22;
const ll INF = 1e9 + 10;
const double PI = acos(-1.0);
const ll MOD = 313;
const double EPS = 1e-12;

int Cal(ll x, ll n) {
    if (x & 1) {
        return x / 2 + 1;
    }
    while ((x & 1) == 0) {
        ll pre = x / 2;
        x = n - pre + x;
    }
    return x / 2 + 1;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n, q;
    while (cin >> n >> q) {
        RE(i, q) {
            ll x;
            cin >> x;
            cout << Cal(x, n) << endl;
        }
    }

    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

long long int n;
int q;

long long int getX(long long int x) {
    while (true) {
        if (x % 2 == 1) return (x + 1) / 2;
        int nextX = (n - x / 2)  + x;
        if (nextX <= n * 2 - 1) {
            x = nextX;
        } else {
            return (x + 1) / 2;
        }
    }
}

int main() {
    cin >> n >> q;;
    /*
    int l;
    for (int i = 1; i <= n; i++) {
        a[i * 2 - 1] = i;
        l = i * 2 - 1;
    }
    int prev = n * 2 - 1 - 1;
    while (prev != 0) {
        a[prev] = a[l];
        a[l] = 0;
        prev -= 2;
        l--;
    }
    */
    long long int x;
    while (q-- > 0) {
        cin >> x;
        cout << getX(x) << endl;
    }
    return 0;
}


#include <iostream>
using namespace std;

int a[100];
long long int n;

long long int getX(long long int x) {
    int counter = 0;
    while (true) {
        if (x % 2 == 1) return (x + 1) / 2;
        int nextX = (n - x / 2)  + x;
        if (nextX <= n * 2 - 1) {
            counter++;
            x = nextX;
        } else {
            return (x + 1) / 2;
        }
    }
    cout << "counter:" << counter << ' ';
}

int main() {
    cin >> n;
    /*
    int l;
    for (int i = 1; i <= n; i++) {
        a[i * 2 - 1] = i;
        l = i * 2 - 1;
    }
    int prev = n * 2 - 1 - 1;
    while (prev != 0) {
        a[prev] = a[l];
        a[l] = 0;
        prev -= 2;
        l--;
    }
    */
    long long int x;
    while (cin >> x) {
        cout << getX(x) << ' ' << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
using namespace std;

long long int n;
int q;

long long int getX(long long int x) {
    while (true) {
        if (x % 2 == 1) return (x + 1) / 2;
        long long int nextX = (n - x / 2)  + x;
        if (nextX <= n * 2 - 1) {
            x = nextX;
        } else {
            return (x + 1) / 2;
        }
    }
}

int main() {
    cin >> n >> q;;
    /*
    int l;
    for (int i = 1; i <= n; i++) {
        a[i * 2 - 1] = i;
        l = i * 2 - 1;
    }
    int prev = n * 2 - 1 - 1;
    while (prev != 0) {
        a[prev] = a[l];
        a[l] = 0;
        prev -= 2;
        l--;
    }
    */
    long long int x;
    while (q-- > 0) {
        cin >> x;
        cout << getX(x) << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a);i<(b);++i)
#define per(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define sz(a) (int)a.size();
#define de(x) cout<<#x<<" = "<<x<<endl
#define dd(x) cout<<#x<<" = "<<x<<" "
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = 100000 + 20;
ll ans = 0;
int main()
{
    ll n, q, p;
    scanf("%I64d%I64d", &n, &q);
    ll two[70] = {1};
    rep(i,1,63) two[i] = two[i - 1] * 2;
 //   de(two[62]);
	while(q--) {
    	scanf("%I64d", &p);
    	if(p &  1)
    	{
    		//2* ans - 1 = p
    		printf("%I64d\n", (p + 1) /2);
		}
		else {
		int step = n - p / 2;
		int l = 0,r = 62,mid;
		while(l < r) {
			mid = l + ((r - l + 1) >> 1);
			if(step % two[mid] == 0){
				l = mid;
			}
			else  r = mid - 1;

		}

		p += step / two[l] * (two[l + 1] - 1);

	/*	while(step % 2 == 0)
		{
		  p += step;
		  step >>=  1;
		}
*/
	/*	p += step;*/
		printf("%I64d\n",(p + 1) / 2);
		}

	//	de(q);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a);i<(b);++i)
#define per(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define sz(a) (int)a.size();
#define de(x) cout<<#x<<" = "<<x<<endl
#define dd(x) cout<<#x<<" = "<<x<<" "
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int N = 100000 + 20;
ll ans = 0;
int main()
{
    ll n, q, p;
    scanf("%I64d%I64d", &n, &q);
    ll two[70] = {1};
    rep(i,1,63) two[i] = two[i - 1] * 2;
 //   de(two[62]);
	while(q--) {
    	scanf("%I64d", &p);
    	if(p &  1)
    	{
    		//2* ans - 1 = p
    		printf("%I64d\n", (p + 1) /2);
		}
		else {
		ll step = n - p / 2;
		int l = 0,r = 62,mid;
		while(l < r) {
			mid = l + ((r - l + 1) >> 1);
			if(step % two[mid] == 0){
				l = mid;
			}
			else  r = mid - 1;

		}

		p += step / two[l] * (two[l + 1] - 1);

	/*	while(step % 2 == 0)
		{
		  p += step;
		  step >>=  1;
		}
*/
	/*	p += step;*/
		printf("%I64d\n",(p + 1) / 2);
		}

	//	de(q);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,q;
    while(~scanf("%lld%lld",&n,&q))
    {
        for(int i=0;i<q;i++)
        {
            ll pos;
            scanf("%lld",&pos);
            int mid=n&1?(n/2+1):n/2;
            if(pos&1)
                printf("%lld\n",pos/2+1);
            else
            {
                if(n&1)
                {
                    ll cnt1=mid+(n-mid)/2;
                    if(pos%4==2)
                        printf("%lld\n",cnt1+(pos-2)/4+1);
                    else
                        printf("%lld\n",mid+pos/4);
                }
                else
                {
                    ll cnt1=mid+(n-mid)/2;
                    if(pos%4==2)
                        printf("%lld\n",mid+(pos-2)/4+1);
                    else
                        printf("%lld\n",cnt1+pos/4);
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n, q, x;
    cin>>n>>q;
    while(q--)
    {
        scanf("%lld",&x);
        while(x%2==0) x = x/2+n;
        printf("%lld\n",(x+1)/2);
    }
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n, q, x;
    cin>>n>>q;
    while(q--)
    {
        scanf("%lld",&x);
        while(x%2==0) x = x/2+n;
        printf("%lld",(x+1)/2);
    }
}


#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define mclear(s) memset(s,0,sizeof(s));
#define MIN 1<<31-1
#define HMAX 1000000000000000000
#define MOD 1000000007
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RSET(s) for(set<int>::iterator it=s.begin();it!=s.end();it++)

typedef long long int ll;
using namespace std;
int kmin(int a=MIN,int b=MIN,int c=MIN,int d=MIN)
{
	return min(min(min(a,b),c),d);
}
int flag[201000];
set<int> se;
int B[201000];
stack<int> zero;
stack<int> one;
int main()
{
	ll n,q;
	cin>>n>>q;
	for(int i=0;i<q;i++)
	{
		ll a;cin>>a;
		if(a%2==1)	cout<<(a+1)/2<<endl;
		else
		{
			while(1)
			{
				a=a+(2*n-a)/2;
				if(a%2==1)
				{
				cout<<(a+1)/2<<endl;
				break;
				}
			}
		}
	}
}
/*0000001100*/


#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define mclear(s) memset(s,0,sizeof(s));
#define MIN 1<<31-1
#define HMAX 1000000000000000000
#define MOD 1000000007
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RSET(s) for(set<int>::iterator it=s.begin();it!=s.end();it++)

typedef long long int ll;
using namespace std;
int kmin(int a=MIN,int b=MIN,int c=MIN,int d=MIN)
{
	return min(min(min(a,b),c),d);
}
int main()
{
	ll n,q;
	cin>>n>>q;
	for(int i=0;i<q;i++)
	{
		ll a;cin>>a;
		if(a%2==1)	cout<<(a+1)/2<<endl;
		else
		{
			while(1)
			{
				a=a+(2*n-a)/2;
				if(a%2==1)
				{
				cout<<(a+1)/2<<endl;
				break;
				}
			}
		}
	}
	return 0;
}
/*0000001100*/


#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define mclear(s) memset(s,0,sizeof(s));
#define MIN 1<<31-1
#define HMAX 1000000000000000000
#define MOD 1000000007
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RSET(s) for(set<int>::iterator it=s.begin();it!=s.end();it++)

typedef long long int ll;
using namespace std;
int kmin(int a=MIN,int b=MIN,int c=MIN,int d=MIN)
{
	return min(min(min(a,b),c),d);
}
int flag[201000];
set<int> se;
int B[201000];
int main()
{
	ll n,q;
	cin>>n>>q;
	for(int i=0;i<q;i++)
	{
		ll a;cin>>a;
		if(a%2==1)	cout<<(a+1)/2<<endl;
		else
		{
			while(1)
			{
				a=a+(2*n-a)/2;
				if(a%2==1)
				{
				cout<<(a+1)/2<<endl;
				break;
				}
			}
		}
	}
	return 0;
}
/*0000001100*/


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define st first
#define	se second
#define mkp make_pair
struct cmp
{
	bool operator()(const pii & a, const pii & b)
	{
		return a.second > b.second;
	}
};
const int maxn = 2e5+5;
char a[maxn];
std::vector<int> vv[maxn];
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	while(m -- )
	{
		int x;
		scanf("%d",&x);
		while(x % 2 == 0)
		{
			x = x + n - (x / 2);
		}
		printf("%d\n",(x + 1) / 2);
	}

}


#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <map>
#include <cmath>
#include <set>
#include <queue>
#include <string>
#include <iostream>
#include <stack>
#include <bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f;
#define st first
#define	se second
#define mkp make_pair
struct cmp
{
	bool operator()(const pii & a, const pii & b)
	{
		return a.second > b.second;
	}
};
const int maxn = 2e5+5;
char a[maxn];
std::vector<int> vv[maxn];
int main()
{
	ll n,m;
	scanf("%lld%lld",&n,&m);
	while(m -- )
	{
		ll x;
		scanf("%lld",&x);
		while(x % 2 == 0)
		{
			x = x + n - (x / 2);
		}
		printf("%lld\n",(x + 1) / 2);
	}

}


#include <iostream>
#include <stdio.h>
using namespace std;
long long n,q,x;
void nhap()
{
    ios_base::sync_with_stdio(0);
    //freopen("A.INP","r",stdin);
    //freopen("A.OUT","w",stdout);
    cin >> n >> q;
}
long long counteven(long long l,long long r)
{
    if (l%2==0 && r%2==0)
    {
        long long v=(r-l)/2+1;
        return v;
    }
    else if (l%2==1 && r%2==1)
    {
        long long v=(r-l)/2;
        return v;
    }
    long long v=(r-l)/2+1;
    return v;
}
void xl()
{
    if (x%2==1)
    {
        cout << (x+1)/2 << '\n';
        return;
    }
    long long l=1,r=n;
    long long vt=x;
    while (vt%2==0)
    {
        long long vt1=r+counteven(l,vt)+1;
        if (vt%2==0)--vt1;
        vt=vt1;
        //cout << vt << ' ';
        int l1=r+1;
        r+=counteven(l,r);
        l=l1;
    }
    cout << (vt+1)/2 << '\n';
}
int main()
{
    nhap();
    for (int i=1;i <= q;++i)
    {
        cin >> x;
        xl();
    }
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
long long n,q,x;
void nhap()
{
    ios_base::sync_with_stdio(0);
    //freopen("A.INP","r",stdin);
    //freopen("A.OUT","w",stdout);
    cin >> n >> q;
}
long long counteven(int l,int r)
{
    if (l%2==0 && r%2==0)
    {
        int v=(r-l)/2+1;
        return v;
    }
    else if (l%2==1 && r%2==1)
    {
        int v=(r-l)/2;
        return v;
    }
    int v=(r-l)/2+1;
    return v;
}
void xl()
{
    if (x%2==1)
    {
        cout << (x+1)/2 << '\n';
        return;
    }
    long long l=1,r=n;
    long long vt=x;
    while (vt%2==0)
    {
        int vt1=r+counteven(l,vt)+1;
        if (vt%2==0)--vt1;
        vt=vt1;
        //cout << vt << ' ';
        int l1=r+1;
        r+=counteven(l,r);
        l=l1;
    }
    cout << (vt+1)/2 << '\n';
}
int main()
{
    nhap();
    for (int i=1;i <= q;++i)
    {
        cin >> x;
        xl();
    }
    return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
long long n,q,x;
void nhap()
{
    ios_base::sync_with_stdio(0);
    //freopen("A.INP","r",stdin);
    //freopen("A.OUT","w",stdout);
    cin >> n >> q;
}
long long counteven(long long l,long long r)
{
    if (l%2==0 && r%2==0)
    {
        long long v=(r-l)/2+1;
        return v;
    }
    else if (l%2==1 && r%2==1)
    {
        long long v=(r-l)/2;
        return v;
    }
    long long v=(r-l)/2+1;
    return v;
}
void xl()
{
    if (x%2==1)
    {
        cout << (x+1)/2 << '\n';
        return;
    }
    long long l=1,r=n;
    long long vt=x;
    while (vt%2==0)
    {
        unsigned long long vt1=r+counteven(l,vt)+1;
        //cout << l << ' ' << r << '\n';
        if (vt%2==0)--vt1;
        vt=vt1;
        //cout << vt << ' ';
        long long l1=r+1;
        r+=counteven(l,r);
        l=l1;
    }
    cout << (vt+1)/2 << '\n';
}
int main()
{
    nhap();
    for (int i=1;i <= q;++i)
    {
        cin >> x;
        xl();
    }
    return 0;
}


#include<stdio.h>
#include<string.h>
#include<queue>
#include<algorithm>
using namespace std;
#define MAXN 200005
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define per(i,j,k) for(int i=j;i>=k;--i)
int main()
{
   long long n,q;
   scanf("%I64d %I64d",&n,&q);
   long long x;
   rep(i,1,q)
   {
       scanf("%I64d",&x);
       long long nn=n;
       while(x%2==0)
       {
           nn--;
           x=x-2;
           if(x==0)
            x=nn;
       }
       x=(x+1)/2;
       printf("%I64d\n",x+(n-nn));
   }
}


#include<stdio.h>
#include<string.h>
#include<queue>
#include<algorithm>
using namespace std;
#define MAXN 200005
#define rep(i,j,k) for(int i=j;i<=k;++i)
#define per(i,j,k) for(int i=j;i>=k;--i)
int main()
{
   long long n,q;
   scanf("%I64d %I64d",&n,&q);
   long long x;
   rep(i,1,q)
   {
       scanf("%I64d",&x);
       long long nn=n;
       while(x%2==0)
       {
           x=nn-x/2;
           nn=x;
       }
       x=(x+1)/2;
       printf("%I64d\n",x+(n-nn));
   }
}


#include <bits/stdc++.h>
using namespace std;

long long n, m, q, x, cnt;

int main() {
//    freopen("../Data/Input1.txt", "r", stdin);
    scanf("%I64d%I64d", &n, &q);
    while(q--) {
        scanf("%I64d", &x);
        cnt = 0;
        for(int m = n; x % 2 == 0; ) {
            cnt += x / 2;
            m = m - x / 2;
            x = m;
        }
        printf("%I64d\n", cnt + (x + 1) / 2);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n, m, q, x, cnt;

int main() {
//    freopen("../Data/Input1.txt", "r", stdin);
    scanf("%I64d%I64d", &n, &q);
    while(q--) {
        scanf("%I64d", &x);
        cnt = 0;
        m = n
        for(; x % 2 == 0; ) {
            cnt += x / 2;
            m = m - x / 2;
            x = m;
        }
        printf("%I64d\n", n - m + (x + 1) / 2);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n, m, q, x, cnt;

int main() {
//    freopen("../Data/Input1.txt", "r", stdin);
    scanf("%I64d%I64d", &n, &q);
    while(q--) {
        scanf("%I64d", &x);
        cnt = 0;
        m = n;
        for(; x % 2 == 0; ) {
            cnt += x / 2;
            m = m - x / 2;
            x = m;
        }
        printf("%I64d\n", n - m + (x + 1) / 2);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n, m, q, x;

int main() {
//    freopen("../Data/Input1.txt", "r", stdin);
    scanf("%I64d%I64d", &n, &q);
    while(q--) {
        scanf("%I64d", &x);
        m = n;
        for(; x % 2 == 0; ) {
            m = m - x / 2;
            x = m;
        }
        printf("%I64d\n", n - m + (x + 1) / 2);
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

long long n, m, q, x, cnt;

int main() {
//    freopen("../Data/Input1.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n >> q;
    while(q--) {
        cin >> x;
        cnt = 0;
        for(int m = n; x % 2 == 0; ) {
            cnt += x / 2;
            m = m - x / 2;
            x = m;
        }
        cout << cnt + (x + 1) / 2 << endl;
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second

using namespace std;

const double pi=acos(-1);
const int N=(int)1e6+7,mod=1000000007,M=2e9;
const ll T=1000000000000000007;

//scanf("%d",&);
ll n,t=1,x,q;
vector<ll>twos;

ll f(ll x){
    for(int i=0;i<60;i++){
        if(x%twos[i]!=0)return x/twos[i-1];
    }
    return 1;
}

int main()
{
//    freopen(".txt","r",stdin);
    while(t<T)twos.pb(t),t*=2;
    cin>>n>>q;
    int p=(n+1)>>1;
    while(q--){
        scanf("%d",&x);
        int m=f(x);
        m+=1;
        m>>=1;
        cout<<m<<endl<<endl;
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second

using namespace std;

const double pi=acos(-1);
const int N=(int)1e6+7,mod=1000000007,M=2e9;

//scanf("%d",&);
ll n,x;
int q;

ll calc(ll x){
    if(x&1)return (x+1)>>1;
    return calc(n+(x>>1));
}

int main()
{
//    freopen(".txt","r",stdin);
    scanf("%I64d%d",&n,&q);
    while(q--){
        scanf("%I64d",&x);
        printf("%I64d\n",calc(x));
    }
    return 0;
}


#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define ff first
#define ss second

using namespace std;

const double pi=acos(-1);
const int N=(int)1e6+7,mod=1000000007,M=2e9;
const ll T=1000000000000000007;

//scanf("%d",&);
ll n,t=1,x,q;
vector<ll>twos;

ll f(ll x){
    for(int i=0;i<60;i++){
        if(x%twos[i]!=0)return x/twos[i-1]+1;
    }
    return 1;
}

int main()
{
//    freopen(".txt","r",stdin);
    while(t<T)twos.pb(t),t*=2;
    cin>>n>>q;
    ll p=2*n;
    while(q--){
        scanf("%d",&x);
        ll m=f(p-x)>>1;
        cout<<n-m+1<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

unsigned long long sol(unsigned long long x, unsigned long long tempn, unsigned long long d, unsigned long long prevn) {
    if (x % 2) {
        return (x + 1) / 2;
    } else {
        unsigned long long tempd = d / 2;
        if (d % 2 && ((tempn + 1) % 2 != 0 || (tempn + d) % 2 != 0)) tempd++;
        sol(tempn + (x - prevn + prevn % 2) / 2, tempn + d, tempd, tempn);
    }
}

int main() {

    unsigned long long n, q;
    cin >> n >> q;
    for (int i = 0; i < q; i++) {
        unsigned long long x;
        cin >> x;
        cout << sol(x, n, n / 2, 0) << "\n";
    }
    return 0;
}

/*
 10 5 2
2 1 1 2 1 1 2 1 2 2
4 10
 3 2
 9 5
9 3
5 7
 */


#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

unsigned long long sol(unsigned long long x, unsigned long long tempn, unsigned long long d, unsigned long long prevn) {
    if (x % 2) {
        return (x + 1) / 2;
    } else {
        unsigned long long tempd = d / 2;
        if (d % 2 && ((tempn + 1) % 2 != 0 || (tempn + d) % 2 != 0)) tempd++;
        sol(tempn + (x - prevn + prevn % 2) / 2, tempn + d, d - tempd, tempn);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    unsigned long long n, q;
    cin >> n >> q;
    for (int i = 0; i < q; i++) {
        unsigned long long x;
        cin >> x;
        cout << sol(x, n, n / 2, 0) << "\n";
    }
    return 0;
}

/*
 10 5 2
2 1 1 2 1 1 2 1 2 2
4 10
 3 2
 9 5
9 3
5 7
 */


#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

unsigned long long sol(unsigned long long x, unsigned long long tempn, unsigned long long d, unsigned long long prevn) {
    if (x % 2) {
        return (x + 1) / 2;
    } else {
        unsigned long long tempd = d / 2;
        if (d % 2 && ((tempn + 1) % 2 != 0 || (tempn + d) % 2 != 0)) tempd++;
        sol(tempn + (x - prevn + prevn % 2) / 2, tempn + d, d - tempd, tempn);
    }
}

int main() {

    unsigned long long n, q;
    cin >> n >> q;
    for (int i = 0; i < q; i++) {
        unsigned long long x;
        cin >> x;
        cout << sol(x, n, n / 2, 0) << "\n";
    }
    return 0;
}

/*
 10 5 2
2 1 1 2 1 1 2 1 2 2
4 10
 3 2
 9 5
9 3
5 7
 */


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n,q,x,t;
    cin>>n>>q;
    while(q--)
    {
        cin>>x;
        if(x&1)
            cout<<(x+1)/2<<"\n";
        else
        {
            t=n-x/2;
            while(t%2==0)
                x+=t,t/=2;
            cout<<(x+t+1)/2<<"\n";
        }
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn = 200005;
long long a[maxn];
long long b[maxn];
int main()
{
    long long n, q;
    scanf("%I64d%I64d", &n, &q);
    for(int i=0; i<q; i++)
    {
        scanf("%I64d", &a[i]);
    }
    for(int i=0; i<q; i++)
    {
        if(a[i]%2==1)
        {
            b[i] = (a[i]+1)/2;
        }
        else
        {
            int t = n-a[i]/2;
            while(t%2==0)
            {
                a[i]+=t;
                t = t/2;
            }
            b[i] = (a[i]+t+1)/2;
        }
    }
    for(int i=0; i<q; i++)
    {
        printf("%I64d\n", b[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2000005;
long long a[maxn];
long long b[maxn];
int main()
{
    long long n, q, x, t;
    scanf("%I64d%I64d", &n, &q);
    while(q--)
    {
        cin>>x;
        if(x&1)
            cout<<(x+1)/2<<"\n";
        else
        {
            t=n-x/2;
            while(t%2==0)
                x+=t,t/=2;
            cout<<(x+t+1)/2<<"\n";
        }
    }
    return 0;
}


#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define inf 03xfxfxf

const int maxn = 10005;
int n, m;
int a[maxn], b[maxn];

int main()
{
    scanf("%d%d", &n, &m);
    for(int i=1; i<=m; i++)
    {
        scanf("%d", &a[i]);
    }
    for(int i=1; i<=m; i++)
    {
        int p = a[i];
        if(p%2==1)
        {
            b[i] = p/2+1;
        }
        else if(p%2 == 0)
        {
            int q1 = p-1;
            int q2 = n-p;
            while(1)
            {
                p+=q2+q1/2+1;
                if(p%2 == 1)
                {
                    b[i] = p/2+1;
                    break;
                }
                q1 = q1/2;
                q2 = q2/2;
            }
        }
    }
    for(int i=1; i<=m; i++)
    {
        printf("%d\n", b[i]);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int maxn = 2000005;
long long a[maxn];
long long b[maxn];
int main()
{
    long long n, q;
    scanf("%I64d%I64d", &n, &q);
    for(int i=0; i<q; i++)
    {
        scanf("%I64d", &a[i]);
    }
    for(int i=0; i<q; i++)
    {
        if(a[i]%2==1)
        {
            b[i] = (a[i]+1)/2;
        }
        else
        {
            int t = n-a[i]/2;
            while(t%2==0)
            {
                a[i]+=t;
                t = t/2;
            }
            b[i] = (a[i]+t+1)/2;
        }
    }
    for(int i=0; i<q; i++)
    {
        printf("%I64d\n", b[i]);
    }
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
#define ll long long
#include<string.h>
#include<queue>
using namespace std;
ll p[100];
ll ans;
ll n;
void dfs(ll tot, ll pos, ll MOD){
	//printf("tot=%lld,pos=%lld, MOD=%lld\n",tot,pos,MOD);
	if (pos%2==MOD||tot==0){
		ans+=pos;
		return;
	}
	ans+=tot;
	dfs(tot/2,pos/2+1-MOD,(MOD+tot%2)%2);
}
int main(){
	ll q;
	p[0]=1;
	for (int i=1;i<61;i++){
		 p[i]=p[i-1]*2;
		 //printf("%d %lld\n",i,p[i]);
	}
	scanf("%lld%lld",&n,&q);
	ll k;
	while (q--){
		ans=0;
		scanf("%lld",&k);
		dfs(n,k,1);
		if (ans%2==0) printf("%lld\n",n);
		else printf("%lld\n",ans/2+1);
	}
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
#define ll long long
#include<string.h>
#include<queue>
using namespace std;
ll p[100];
ll ans;
ll n;
void dfs(ll tot, ll pos, ll MOD){
	//printf("tot=%lld,pos=%lld, MOD=%lld\n",tot,pos,MOD);
	if (pos%2==MOD||tot==0){
		ans+=pos;
		return;
	}
	ans+=tot;
	dfs(tot/2+(tot%2)*(1-MOD),pos/2+1-MOD,(MOD+tot%2)%2);
}
int main(){
	ll q;
	p[0]=1;
	for (int i=1;i<61;i++){
		 p[i]=p[i-1]*2;
		 //printf("%d %lld\n",i,p[i]);
	}
	scanf("%lld%lld",&n,&q);
	ll k;
	while (q--){
		ans=0;
		scanf("%lld",&k);
		dfs(n,k,1);
		if (ans%2==0) printf("%lld\n",n);
		else printf("%lld\n",ans/2+1);
	}
	return 0;
}


#include<stdio.h>
#include<iostream>
#include<algorithm>
#define ll long long
#include<string.h>
#include<queue>
using namespace std;
ll p[100];
ll ans;
ll n;
void dfs(ll tot, ll pos, ll MOD){
	printf("tot=%lld,pos=%lld, MOD=%lld\n",tot,pos,MOD);
	if (pos%2==MOD||tot==0){
		ans+=pos;
		return;
	}
	ans+=tot;
	dfs(tot/2+(tot%2)*(1-MOD),pos/2+1-MOD,(MOD+tot%2)%2);
}
int main(){
	ll q;
	p[0]=1;
	for (int i=1;i<61;i++){
		 p[i]=p[i-1]*2;
		 //printf("%d %lld\n",i,p[i]);
	}
	scanf("%lld%lld",&n,&q);
	ll k;
	while (q--){
		ans=0;
		scanf("%lld",&k);
		dfs(n,k,1);
		if (ans%2==0) printf("%lld\n",n);
		else printf("%lld\n",ans/2+1);
	}
	return 0;
}


#include <cstdio>

long long n;
int Qi;

int Solve(int l, int x, int bl) {
	if (bl) {
		if (x == 1) return Solve(l, n - l + 1, 0);
		return Solve(l, x - 1, 0);
	}
	if (x & 1) return l + x / 2;
	int md = (l + n) >> 1;
	if ((n - l + 1) & 1) return Solve(md + 1, x / 2, 1);
	return Solve(md + 1, x / 2, 0);
}

int main() {
	scanf("%lld%d", &n, &Qi);
	for (long long x; Qi; --Qi) {
		scanf("%lld", &x);
		printf("%lld\n", Solve(1, x, 0));
	}

	return 0;
}


#include <cstdio>

long long n;
int Qi;

long long Solve(long long l, long long x, int bl) {
	if (bl) {
		if (x == 1) return Solve(l, n - l + 1, 0);
		return Solve(l, x - 1, 0);
	}
	if (x & 1) return l + x / 2;
	int md = (l + n) >> 1;
	if ((n - l + 1) & 1) return Solve(md + 1, x / 2, 1);
	return Solve(md + 1, x / 2, 0);
}

int main() {
	scanf("%lld%d", &n, &Qi);
	for (long long x; Qi; --Qi) {
		scanf("%lld", &x);
		printf("%lld\n", Solve(1, x, 0));
	}

	return 0;
}


#include <cstdio>

typedef long long LL;

LL n;
int Qi;

LL Solve(LL l, LL x, int bl) {
	if (bl) {
		if (x == 1) return Solve(l, n - l + 1, 0);
		return Solve(l, x - 1, 0);
	}
	if (x & 1) return l + x / 2;
	LL md = (l + n) >> 1;
	if ((n - l + 1) & 1) return Solve(md + 1, x / 2, 1);
	return Solve(md + 1, x / 2, 0);
}

int main() {
	scanf("%lld%d", &n, &Qi);
	for (LL x; Qi; --Qi) {
		scanf("%lld", &x);
		printf("%lld\n", Solve(1, x, 0));
	}

	return 0;
}


//Hello Wolrd
#include<cstdio>
#include<ctype.h>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pc putchar
#define RG register
#ifdef LOCAL
char __wzp[1<<15|1],*__S=__wzp+32768;
#define gc() (__S>=__wzp+32768?(__wzp[fread(__wzp,sizeof(char),1<<15,stdin)]=EOF),*((__S=__wzp)++):*(__S++))
#else
#define gc getchar
#endif
inline ll read(){
	RG ll x=0,f=1;RG char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){
	if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');
}
void writeln(ll x){
	write(x);puts("");
}
#define rd read
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Down(i,a,b) for(RG int i=(a);i>=(b);--i)
#define fin(x) {freopen(#x".in","r",stdin);}
#define fout(x) {freopen(#x".in","w",stdout);}
#define y1 _________y1
#define hash _____hash
#define union ___union
int tot = 0;
int main(){
	int n = rd(),Q = rd();
	while(Q--){
		int k = rd();
		while((k&1)==0) k+=n-k/2;
		printf("%d\n",(k+1)/2);
	}
	return 0;
}


//Hello Wolrd
#include<cstdio>
#include<ctype.h>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pc putchar
#define RG register
#ifdef LOCAL
char __wzp[1<<15|1],*__S=__wzp+32768;
#define gc() (__S>=__wzp+32768?(__wzp[fread(__wzp,sizeof(char),1<<15,stdin)]=EOF),*((__S=__wzp)++):*(__S++))
#else
#define gc getchar
#endif
inline ll read(){
	RG ll x=0,f=1;RG char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){
	if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');
}
void writeln(ll x){
	write(x);puts("");
}
#define rd read
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Down(i,a,b) for(RG int i=(a);i>=(b);--i)
#define fin(x) {freopen(#x".in","r",stdin);}
#define fout(x) {freopen(#x".in","w",stdout);}
#define y1 _________y1
#define hash _____hash
#define union ___union
#define int ll
int tot = 0;
signed main(){
	int n = rd(),Q = rd();
	while(Q--){
		int k = rd();
		while((k&1)==0) k+=n-k/2;
		printf("%I64d\n",(k+1)/2);
	}
	return 0;
}


//Hello Wolrd
#include<cstdio>
#include<ctype.h>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define pc putchar
#define RG register
#ifdef LOCAL
char __wzp[1<<15|1],*__S=__wzp+32768;
#define gc() (__S>=__wzp+32768?(__wzp[fread(__wzp,sizeof(char),1<<15,stdin)]=EOF),*((__S=__wzp)++):*(__S++))
#else
#define gc getchar
#endif
inline ll read(){
	RG ll x=0,f=1;RG char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
void write(ll x){
	if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');
}
void writeln(ll x){
	write(x);puts("");
}
#define rd read
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define mp make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Down(i,a,b) for(RG int i=(a);i>=(b);--i)
#define fin(x) {freopen(#x".in","r",stdin);}
#define fout(x) {freopen(#x".in","w",stdout);}
#define y1 _________y1
#define hash _____hash
#define union ___union
#define int ll
int tot = 0;
int main(){
	int n = rd(),Q = rd();
	while(Q--){
		int k = rd();
		while((k&1)==0) k+=n-k/2;
		printf("%I64d\n",(k+1)/2);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    long long int q, a;
    cin >> n;
    cin >> q;
    for(int i = 0;i < q; i++){
        cin >> a;
        long long int l = a - 1, r = n - a, p = n;
        while(a % 2 == 0){
            l/= 2;
            r/= 2;
            p += l;
            a = p + 1;
            p++;
            p += r;
        }
        cout << (a + 1) / 2 << endl;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    long long int n;
    int q, a;
    cin >> n;
    cin >> q;
    for(int i = 0;i < q; i++){
        cin >> a;
        int l = a - 1, r = n - a, p = n;
        while(a % 2 == 0){
            l/= 2;
            r/= 2;
            p += l;
            a = p + 1;
            p++;
            p += r;
        }
        cout << (a + 1) / 2 << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long working(long long n, long long x) {
            long long ans = 0;
            long long m = n;

            while (true) {
                if (x % 2 == 1) {
                    ans += x/2 + 1;
                    break;
                } else {
                    ans += (m+1) / 2;
                    x = x / 2;
                    m = m / 2;
//                    cout << ans << " " << x << " " << m << endl;
                }
            }
    return ans;
}

long long f(long long n, long long k) {
    if (k % 2 == 1) {
        return (k + 1) / 2;
    } else if (n == 1) {
        return 1;
    } else if (k == 2) {
        return f(n-1, n-1) + 1;
    } else {
        //(k % 2 == 0 && k > 2)
        int t = k / 2;
        return f(n - t + 1, 2) + t - 1;
    }
}

int main() {
//    for (int n = 3; n <= 20; n++) {
//        vector <int> a(2 * n);
//        for (int i = 1; i <= n; i++)
//            a[2 * i - 1] = i;
//        while (true) {
//            int j = 2 * n - 1;
//            while (a[j] == 0) j--;
//            if (j == n) break;
//            int i = j;
//            while (a[i] != 0) i--;
//            a[i] = a[j]; a[j] = 0;
//        }
//        cout << "n = " << n << endl;
//        for (int i = 1; i <= n; i++) {
//                    cout << a[i] << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++) {
//            cout << f(n, i) << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++)
//            if (f(n, i) != a[i]) {
//                cout << n << " " << i << " " << working(n, i) << " " << a[i] << endl;
//            }
//        cout << endl;
//    }

    long long n;
    int q;
    cin >> n >> q;
    while (q--) {
        long long x;
        scanf("%I64d", &x);
        printf("%I64d\n", f(n, x));
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long working(long long n, long long x) {
            long long ans = 0;
            long long m = n;

            while (true) {
                if (x % 2 == 1) {
                    ans += x/2 + 1;
                    break;
                } else {
                    ans += (m+1) / 2;
                    x = x / 2;
                    m = m / 2;
//                    cout << ans << " " << x << " " << m << endl;
                }
            }
    return ans;
}

long long f(long long n, long long k) {
    if (k % 2 == 1) {
        return (k + 1) / 2;
    } else if (n == 1) {
        return 1;
    } else if (k == 2) {
        return f(n-1, n-1) + 1;
    } else {
        //(k % 2 == 0 && k > 2)
        int t = k / 2;
        return f(n - t + 1, 2) + t - 1;
    }
}

int main() {
//    cout << f(10000000000000000, 10000000000000000) << endl;;
//    for (int n = 3; n <= 20; n++) {
//        vector <int> a(2 * n);
//        for (int i = 1; i <= n; i++)
//            a[2 * i - 1] = i;
//        while (true) {
//            int j = 2 * n - 1;
//            while (a[j] == 0) j--;
//            if (j == n) break;
//            int i = j;
//            while (a[i] != 0) i--;
//            a[i] = a[j]; a[j] = 0;
//        }
//        cout << "n = " << n << endl;
//        for (int i = 1; i <= n; i++) {
//                    cout << a[i] << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++) {
//            cout << f(n, i) << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++)
//            if (f(n, i) != a[i]) {
//                cout << n << " " << i << " " << working(n, i) << " " << a[i] << endl;
//            }
//        cout << endl;
//    }

    scanf("%I64d", &n);
    scanf("%d", q);
    while (q--) {
        long long x;
        scanf("%I64d", &x);
        printf("%I64d\n", f(n, x));
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long working(long long n, long long x) {
            long long ans = 0;
            long long m = n;

            while (true) {
                if (x % 2 == 1) {
                    ans += x/2 + 1;
                    break;
                } else {
                    ans += (m+1) / 2;
                    x = x / 2;
                    m = m / 2;
//                    cout << ans << " " << x << " " << m << endl;
                }
            }
    return ans;
}

long long f(long long n, long long k) {
    if (k % 2 == 1) {
        return (k + 1) / 2;
    } else if (n == 1) {
        return 1;
    } else if (k == 2) {
        return f(n-1, n-1) + 1;
    } else {
        //(k % 2 == 0 && k > 2)
        int t = k / 2;
        return f(n - t + 1, 2) + t - 1;
    }
}

int main() {
//    cout << f(10000000000000000, 10000000000000000) << endl;;
//    for (int n = 3; n <= 20; n++) {
//        vector <int> a(2 * n);
//        for (int i = 1; i <= n; i++)
//            a[2 * i - 1] = i;
//        while (true) {
//            int j = 2 * n - 1;
//            while (a[j] == 0) j--;
//            if (j == n) break;
//            int i = j;
//            while (a[i] != 0) i--;
//            a[i] = a[j]; a[j] = 0;
//        }
//        cout << "n = " << n << endl;
//        for (int i = 1; i <= n; i++) {
//                    cout << a[i] << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++) {
//            cout << f(n, i) << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++)
//            if (f(n, i) != a[i]) {
//                cout << n << " " << i << " " << working(n, i) << " " << a[i] << endl;
//            }
//        cout << endl;
//    }

    long long n;
    int q;
    scanf("%I64d", &n);
    scanf("%d", q);
    while (q--) {
        long long x;
        scanf("%I64d", &x);
        printf("%I64d\n", f(n, x));
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long working(long long n, long long x) {
            long long ans = 0;
            long long m = n;

            while (true) {
                if (x % 2 == 1) {
                    ans += x/2 + 1;
                    break;
                } else {
                    ans += (m+1) / 2;
                    x = x / 2;
                    m = m / 2;
//                    cout << ans << " " << x << " " << m << endl;
                }
            }
    return ans;
}

long long f(long long n, long long k) {
    if (k % 2 == 1) {
        return (k + 1) / 2;
    } else if (n == 1) {
        return 1;
    } else if (k == 2) {
        return f(n-1, n-1) + 1;
    } else {
        //(k % 2 == 0 && k > 2)
        int t = k / 2;
        return f(n - t + 1, 2) + t - 1;
    }
}

int main() {
//    for (int n = 3; n <= 20; n++) {
//        vector <int> a(2 * n);
//        for (int i = 1; i <= n; i++)
//            a[2 * i - 1] = i;
//        while (true) {
//            int j = 2 * n - 1;
//            while (a[j] == 0) j--;
//            if (j == n) break;
//            int i = j;
//            while (a[i] != 0) i--;
//            a[i] = a[j]; a[j] = 0;
//        }
//        cout << "n = " << n << endl;
//        for (int i = 1; i <= n; i++) {
//                    cout << a[i] << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++) {
//            cout << f(n, i) << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++)
//            if (f(n, i) != a[i]) {
//                cout << n << " " << i << " " << working(n, i) << " " << a[i] << endl;
//            }
//        cout << endl;
//    }

    long long n;
    int q;
    cin >> n >> q;
    while (q--) {
        long long x;
        cin >> x;
        cout << f(n, x) << endl;
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long working(long long n, long long x) {
            long long ans = 0;
            long long m = n;

            while (true) {
                if (x % 2 == 1) {
                    ans += x/2 + 1;
                    break;
                } else {
                    ans += (m+1) / 2;
                    x = x / 2;
                    m = m / 2;
//                    cout << ans << " " << x << " " << m << endl;
                }
            }
    return ans;
}

long long f(long long n, long long k) {
    if (k % 2 == 1) {
        return (k + 1) / 2;
    } else if (n == 1) {
        return 1;
    } else if (k == 2) {
        return f(n-1, n-1) + 1;
    } else {
        //(k % 2 == 0 && k > 2)
        long long t = k / 2;
        return f(n - t + 1, 2) + t - 1;
    }
}

int main() {
//    cout << f(10000000000000000, 10000000000000000) << endl;;
//    for (int n = 3; n <= 20; n++) {
//        vector <int> a(2 * n);
//        for (int i = 1; i <= n; i++)
//            a[2 * i - 1] = i;
//        while (true) {
//            int j = 2 * n - 1;
//            while (a[j] == 0) j--;
//            if (j == n) break;
//            int i = j;
//            while (a[i] != 0) i--;
//            a[i] = a[j]; a[j] = 0;
//        }
//        cout << "n = " << n << endl;
//        for (int i = 1; i <= n; i++) {
//                    cout << a[i] << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++) {
//            cout << f(n, i) << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++)
//            if (f(n, i) != a[i]) {
//                cout << n << " " << i << " " << working(n, i) << " " << a[i] << endl;
//            }
//        cout << endl;
//    }

    long long n;
    int q;
    scanf("%I64d", &n);
//    cin >> n;
    scanf("%d", &q);
    while (q--) {
        long long x;
        scanf("%I64d", &x);
        printf("%I64d\n", f(n, x));
//        cin >> x;
//        cout << f(n, x) << endl;
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long working(long long n, long long x) {
            long long ans = 0;
            long long m = n;

            while (true) {
                if (x % 2 == 1) {
                    ans += x/2 + 1;
                    break;
                } else {
                    ans += (m+1) / 2;
                    x = x / 2;
                    m = m / 2;
//                    cout << ans << " " << x << " " << m << endl;
                }
            }
    return ans;
}

long long f(long long n, long long k) {
    if (k % 2 == 1) {
        return (k + 1) / 2;
    } else if (n == 1) {
        return 1;
    } else if (k == 2) {
        return f(n-1, n-1) + 1;
    } else {
        //(k % 2 == 0 && k > 2)
        int t = k / 2;
        return f(n - t + 1, 2) + t - 1;
    }
}

int main() {
//    cout << f(10000000000000000, 10000000000000000) << endl;;
//    for (int n = 3; n <= 20; n++) {
//        vector <int> a(2 * n);
//        for (int i = 1; i <= n; i++)
//            a[2 * i - 1] = i;
//        while (true) {
//            int j = 2 * n - 1;
//            while (a[j] == 0) j--;
//            if (j == n) break;
//            int i = j;
//            while (a[i] != 0) i--;
//            a[i] = a[j]; a[j] = 0;
//        }
//        cout << "n = " << n << endl;
//        for (int i = 1; i <= n; i++) {
//                    cout << a[i] << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++) {
//            cout << f(n, i) << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++)
//            if (f(n, i) != a[i]) {
//                cout << n << " " << i << " " << working(n, i) << " " << a[i] << endl;
//            }
//        cout << endl;
//    }

    long long n;
    int q;
    scanf("%I64d", &n);
    scanf("%d", &q);
    while (q--) {
        long long x;
        scanf("%I64d", &x);
        printf("%I64d\n", f(n, x));
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

long long working(long long n, long long x) {
            long long ans = 0;
            long long m = n;

            while (true) {
                if (x % 2 == 1) {
                    ans += x/2 + 1;
                    break;
                } else {
                    ans += (m+1) / 2;
                    x = x / 2;
                    m = m / 2;
//                    cout << ans << " " << x << " " << m << endl;
                }
            }
    return ans;
}

long long f(long long n, long long k) {
    if (k % 2 == 1) {
        return (k + 1) / 2;
    } else if (n == 1) {
        return 1;
    } else if (k == 2) {
        return f(n-1, n-1) + 1;
    } else {
        //(k % 2 == 0 && k > 2)
        long long t = k / 2;
        return f(n - t + 1, 2) + t - 1;
    }
}

int main() {
//    cout << f(10000000000000000, 10000000000000000) << endl;;
//    for (int n = 3; n <= 20; n++) {
//        vector <int> a(2 * n);
//        for (int i = 1; i <= n; i++)
//            a[2 * i - 1] = i;
//        while (true) {
//            int j = 2 * n - 1;
//            while (a[j] == 0) j--;
//            if (j == n) break;
//            int i = j;
//            while (a[i] != 0) i--;
//            a[i] = a[j]; a[j] = 0;
//        }
//        cout << "n = " << n << endl;
//        for (int i = 1; i <= n; i++) {
//                    cout << a[i] << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++) {
//            cout << f(n, i) << " ";
//        }
//        cout << endl;
//        for (int i = 1; i <= n; i++)
//            if (f(n, i) != a[i]) {
//                cout << n << " " << i << " " << working(n, i) << " " << a[i] << endl;
//            }
//        cout << endl;
//    }

    long long n;
    int q;
//    scanf("%I64d", &n);
    cin >> n >> q;
//    scanf("%d", &q);
    while (q--) {
        long long x;
        cin >> x;
//        scanf("%I64d", &x);
//        printf("%I64d\n", f(n, x));
//        cin >> x;
        cout << f(n, x) << endl;
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define point pair<int,int>
#define pb push_back
#define X first
#define Y second
#define engl "\n"
int in(){int32_t x ; scanf("%d",&x) ;  return x ;}
inline long long lin() {long long x ; scanf("%lld",&x) ; return x ;}
inline void read(int *a , int n) {for (int i = 0 ; i < n ; i ++) a[i] = in();}
inline void readL(int *a , int n) {for (int i = 0 ; i < n ; i ++) a[i] = lin();}
const int maxn = 2e6 + 10;
const int mod = 1e9 + 7;
const int MAX_VAL = 1e18 + 10;
const int MAGIC = 350;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
inline int f(int n , int pos)
{
    if (pos % 2 == 0 ) return pos/2;
    if (n % 2 == 0) return n/2 + f(n/2,pos/2);
    int newPos = (pos/2 - 1 + n/2)%(n/2);
    return f(n/2,newPos) + (n+1)/2;
}
int32_t main()
{
    int n = lin() , q = in();
    while (q --){
        int pos = in() -  1;
        cout << f(n,pos) + 1 << "\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define point pair<int,int>
#define pb push_back
#define X first
#define Y second
#define engl "\n"
int in(){int32_t x ; scanf("%d",&x) ;  return x ;}
inline long long lin() {long long x ; scanf("%lld",&x) ; return x ;}
inline void read(int *a , int n) {for (int i = 0 ; i < n ; i ++) a[i] = in();}
inline void readL(int *a , int n) {for (int i = 0 ; i < n ; i ++) a[i] = lin();}
const int maxn = 2e6 + 10;
const int mod = 1e9 + 7;
const int MAX_VAL = 1e18 + 10;
const int MAGIC = 350;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
inline int f(int n , int pos)
{
    if (pos % 2 == 0 ) return pos/2;
    if (n % 2 == 0) return n/2 + f(n/2,pos/2);
    int newPos = (pos/2 - 1 + n/2)%(n/2);
    return f(n/2,newPos) + (n+1)/2;
}
int32_t main()
{
    int n = lin() , q = in();
    while (q --){
        int pos = lin() -  1;
        cout << f(n,pos) + 1 << "\n";
    }
}


#include <bits/stdc++.h>

#define LL long long int
#define F first
#define S second
#define MP make_pair
#define MAX(a, b) (a>b? a: b)
#define MIN(a, b) (a<b? a: b)
using namespace std;
typedef pair<int, int> PII;

int n, q;

int main(){
	scanf("%d %d", &n, &q);
	for (int i=0; i<q; i++){
		int p, iter;
		scanf("%d", &p);
		iter = p;
		while ((iter&1) == 0){
			iter += n - (iter>>1);
		}
		printf("%d\n", (iter+1)>>1);
	}
	return 0;
}


#include <bits/stdc++.h>

#define LL long long int
#define F first
#define S second
#define MP make_pair
#define MAX(a, b) (a>b? a: b)
#define MIN(a, b) (a<b? a: b)
using namespace std;
typedef pair<int, int> PII;

LL n, q;

int main(){
	scanf("%lld %lld", &n, &q);
	for (int i=0; i<q; i++){
		LL p, iter;
		scanf("%lld", &p);
		iter = p;
		while ((iter&1) == 0){
			iter += n - (iter>>1);
		}
		printf("%lld\n", (iter+1)>>1);
	}
	return 0;
}


#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;

ll n;

ll answ(ll k)
{
 ll ncur = n;
 ll toadd = 0;
 while ((k&1) == 0)
 {
  k >>= 1;
  ll delt = (ncur+1)/2;
  toadd += delt;
  if ((ncur&1) == 1) --k;
  ncur -= delt;
  if (k == 0) k = ncur;
 }
 return (k>>1) + 1 + toadd;
}

int main()
{
 int q;
 cin >> n >> q;
 for (int i = 0; i < q; ++i)
 {
  int u;
  cin >> u;
  cout << answ(u) << "\n";
 }

 return 0;
}


#include <iostream>
#include <string>
#include <vector>
using namespace std;
using ll = long long int;

ll n;

ll answ(ll k)
{
 ll ncur = n;
 ll toadd = 0;
 while ((k&1) == 0)
 {
  k >>= 1;
  ll delt = (ncur+1)/2;
  toadd += delt;
  if ((ncur&1) == 1) --k;
  ncur -= delt;
  if (k == 0) k = ncur;
 }
 return (k>>1) + 1 + toadd;
}

int main()
{
 int q;
 cin >> n >> q;
 for (int i = 0; i < q; ++i)
 {
  ll u;
  cin >> u;
  cout << answ(u) << "\n";
 }

 return 0;
}


#include<bits/stdc++.h>
using namespace std;
//http://blog.csdn.net/swust5120160705/article/details/79505368
#define ll long long
#define max_int 0x7fffffff
#define min_int 0x80000000
#define rep(i,j,k) for (int i=j; i<k; i++)
const int maxn = 200050;
ll get_blank(ll st, ll ed){
	return (ed-st)/2;
}
ll fuck, n, q, tmp, last_pos, q0;
int main(){
	scanf("%lld%lld", &n, &q);
	rep(i, 0, q){
		scanf("%lld", &q0);
		tmp=q0;
		if (tmp%2) {
			printf("%lld\n", (q0+1)/2);
			continue;
		}
		last_pos=tmp;
		tmp=n+get_blank(1, tmp-1)+1;
		while (tmp%2==0){
			fuck=tmp;
			tmp=tmp+get_blank(last_pos+1, tmp-1)+1;
			last_pos=fuck;
		}
	printf("%lld\n", (tmp+1)/2);
	}

}


#include<bits/stdc++.h>
using namespace std;
//http://blog.csdn.net/swust5120160705/article/details/79505368
#define ll long long
#define max_int 0x7fffffff
#define min_int 0x80000000
#define rep(i,j,k) for (int i=j; i<k; i++)
const int maxn = 200050;
ll get_blank(ll st, ll ed){
	return (ed-st)/2;
}
ll fuck, n, q, tmp, last_pos, q0;
int main(){
	scanf("%lld%lld", &n, &q);
	rep(i, 0, q){
		scanf("%lld", &q0);
		tmp=q0;
		if (tmp%2) {
			printf("%lld\n", (q0+1)/2);
			continue;
		}
		last_pos=tmp;
		tmp=n+get_blank(1, tmp-1)+1;
		while (tmp%2==0){
			fuck=tmp;
			tmp=tmp+get_blank(last_pos+1, tmp-1)+1;
			last_pos=fuck;
		}
	printf("%d\n", (tmp+1)/2);
	}

}


#include<bits/stdc++.h>
using namespace std;
//http://blog.csdn.net/swust5120160705/article/details/79505368
#define ll long long
#define max_int 0x7fffffff
#define min_int 0x80000000
#define rep(i,j,k) for (int i=j; i<k; i++)
const int maxn = 200050;
int get_blank(int st, int ed){
	return (ed-st)/2;
}
int fuck, n, q, tmp, last_pos, q0;
int main(){
	scanf("%d%d", &n, &q);
	rep(i, 0, q){
		scanf("%d", &q0);
		tmp=q0;
		if (tmp%2) {
			printf("%d\n", (q0+1)/2);
			continue;
		}
		last_pos=tmp;
		tmp=n+get_blank(1, tmp-1)+1;
		while (tmp%2==0){
			fuck=tmp;
			tmp=tmp+get_blank(last_pos+1, tmp-1)+1;
			last_pos=fuck;
		}
	printf("%d\n", (tmp+1)/2);
	}

}


#include<bits/stdc++.h>
using namespace std;
//http://blog.csdn.net/swust5120160705/article/details/79505368
#define ll long long
#define max_int 0x7fffffff
#define min_int 0x80000000
#define rep(i,j,k) for (int i=j; i<k; i++)
const int maxn = 200050;
int get_blank(int st, int ed){
	return (ed-st)/2;
}
ll fuck, n, q, tmp, last_pos, q0;
int main(){
	scanf("%lld%lld", &n, &q);
	rep(i, 0, q){
		scanf("%lld", &q0);
		tmp=q0;
		if (tmp%2) {
			printf("%lld\n", (q0+1)/2);
			continue;
		}
		last_pos=tmp;
		tmp=n+get_blank(1, tmp-1)+1;
		while (tmp%2==0){
			fuck=tmp;
			tmp=tmp+get_blank(last_pos+1, tmp-1)+1;
			last_pos=fuck;
		}
	printf("%d\n", (tmp+1)/2);
	}

}


#include <bits/stdc++.h>
using namespace std;

const int N = 5000 * 100 + 5;
long long n, m, sup[N], num[N], t;
vector <long long> adj[N], ans, q[N];

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n >> m;
	for (int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++)
		cin >> sup[i], num[i] = 1, q[sup[i]].push_back(i);
	for (int i = 1; i <= n; i++)
		for (auto u : q[i]) {
			if (num[u] == sup[u]) {
				ans.push_back(u);
				for (auto e : adj[u])
					if (num[u] == num[e])
						num[e] = num[u] + 1;
			}
			else
				return cout << -1 << endl, 0;
		}
	for (auto u : ans)
		cout << u << ' ';
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 5000 * 100 + 5;
long long n, m, sup[N], num[N], t;
vector <long long> adj[N], ans, q[N];

int main() {
	cin >> n >> m;
	for (int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++)
		cin >> sup[i], num[i] = 1, q[sup[i]].push_back(i);
	for (int i = 1; i <= n; i++)
		for (auto u : q[i]) {
			if (num[u] == sup[u]) {
				ans.push_back(u);
				for (auto e : adj[u])
					if (num[u] == num[e])
						num[e] = num[u] + 1;
			}
			else
				return cout << -1 << endl, 0;
		}
	for (auto u : ans)
		cout << u << ' ';
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;

const int N = 5000 * 100 + 5;
long long n, m, sup[N], num[N], t;
vector <long long> adj[N], ans, q[N];
bool vis[N], flag = true;

void f(int v) {
	for (auto u : adj[v])
		if (num[v] == num[u])
			num[u] = num[v] + 1;
}

int main() {
	cin >> n >> m;
	for (int i = 0, u, v; i < m; i++) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++)
		cin >> sup[i], num[i] = 1, q[sup[i]].push_back(i);
	for (int i = 1; i <= n; i++)
		for (auto u : q[i]) {
			if (num[u] == sup[u])
				f(u), ans.push_back(u);
			else
				return cout << -1 << endl, 0;
		}
	if (flag)
		for (auto u : ans)
			cout << u << ' ';
	cout << endl;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 5e5 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
bool vis[SZ];
bool cmp(tt a,tt b)
{
	if(a.t != b.t)
	return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u,int far)
{
	vis[u] = 1;
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		if(v == far || vis[v] == 1) continue;
		if(A[v].t == A[u].t)
		{
			return 0;
		}
		if(!dfs(v,u)) return 0;
	}
	return 1;
}

int main()
{
	memset(vis,0,sizeof(vis));
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		A[i].id = i;
	}
	if(dfs(1,1))
	{
		sort(A + 1,A + n + 1,cmp);
		for(int i = 1;i <= n;i ++) printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int SZ = 1e6 + 20;
int temp,n,m,fist[SZ],sub[SZ];
struct zt
{
	int v,nxt;
}line[SZ << 1];
pair<int, int> t[SZ];
inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

int main()
{
	int a,b;
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		sub[i] = 1;
		t[i].second = i;
		scanf("%d",&t[i].first);
	}
	sort(t + 1,t + n + 1);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		int x = t[i].second;
		if(t[i].first != sub[x])
		{
			flag = 0;
			break;
		}
		for(int j = fist[t[i].second];j != -1;j = line[j].nxt)
		{
			int v = line[j].v;
			if(sub[v] == t[i].first) sub[v] ++;
		}
	}
	if(flag == 0)
	{
		printf("-1\n");
		return 0;
	}
	for(int i = 1;i <= n;i ++)
	 	printf("%d ",t[i].second);
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
map<int,int> mp;
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	int vis[mp[u] + 1];
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		if(mp[v] <= mp[u])
		vis[mp[v]] = 1;
	}
	for(int i = 1;i <= mp[u] - 1;i ++)
	if(vis[i] == 0) return 0;
	if(vis[mp[u]] == 1) return 0;
	return 1;
}

int main()
{
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		mp[i] = A[i].t;
		A[i].id = i;
	}
	sort(A + 1,A + n + 1,cmp);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(dfs(A[i].id) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		for(int i = 1;i <= n;i ++)
		printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
map<int,int> mp;
bool vis[SZ];
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	memset(vis,0,sizeof(vis));
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		vis[mp[v]] = 1;
	}
	for(int i = 1;i <= mp[u] - 1;i ++)
		if(vis[i] == 0) return 0;
	if(vis[mp[u]] == 1) return 0;
	return 1;
}

int main()
{
	memset(vis,0,sizeof(vis));
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		mp[i] = A[i].t;
		A[i].id = i;
	}
	sort(A + 1,A + n + 1,cmp);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(dfs(A[i].id) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		for(int i = 1;i <= n;i ++)
		printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
map<int,int> mp;
bool vis[SZ];
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		vis[mp[v]] = 1;
	}
	for(int i = 1;i <= mp[u] - 1;i ++)
	{
		if(vis[i] == 0) return 0;
		vis[i] = 0;
	}
	if(vis[mp[u]] == 1) return 0;
	return 1;
}

int main()
{
	memset(vis,0,sizeof(vis));
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		mp[i] = A[i].t;
		A[i].id = i;
	}
	sort(A + 1,A + n + 1,cmp);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(dfs(A[i].id) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		for(int i = 1;i <= n;i ++)
		printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
map<int,int> mp;
bool vis[SZ];
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	memset(vis,0,sizeof(vis));
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		vis[mp[v]] = 1;
	}
	for(int i = 1;i <= mp[u] - 1;i ++)
		if(vis[i] == 0) return 0;
	return 1;
}

int main()
{
	memset(vis,0,sizeof(vis));
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		mp[i] = A[i].t;
		A[i].id = i;
	}
	sort(A + 1,A + n + 1,cmp);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(dfs(A[i].id) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		for(int i = 1;i <= n;i ++)
		printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//__builtin_popcount(n);
//-std=c++11
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define RI register int
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int SZ = 1e6 + 10;
int n,m;
int a,b,fist[SZ];
int temp;
struct tt
{
	int t;
	int id;
}A[SZ];
map<int,int> mp;
bool cmp(tt a,tt b)
{
	if(a.t != b.t) return a.t < b.t;
	else return a.id < b.id;
}
struct zt
{
	int v,nxt;
}line[SZ << 1];

inline void build(int x,int y)
{
	line[++ temp] = (zt){y,fist[x]};
	fist[x] = temp;
}

inline bool dfs(int u)
{
	int vis[mp[u] + 1];
	for(int i = fist[u];i != -1;i = line[i].nxt)
	{
		int v = line[i].v;
		vis[mp[v]] = 1;
	}
	for(int i = 1;i <= mp[u] - 1;i ++)
	if(vis[i] == 0) return 0;
	if(vis[mp[u]] == 1) return 0;

	return 1;
}

int main()
{
	memset(fist,-1,sizeof(fist));
	scanf("%d%d",&n,&m);
	for(int i = 1;i <= m;i ++)
	{
		scanf("%d%d",&a,&b);
		build(a,b);
		build(b,a);
	}
	for(int i = 1;i <= n;i ++)
	{
		scanf("%d",&A[i].t);
		mp[i] = A[i].t;
		A[i].id = i;
	}
	sort(A + 1,A + n + 1,cmp);
	int flag = 1;
	for(int i = 1;i <= n;i ++)
	{
		if(dfs(A[i].id) == 0)
		{
			flag = 0;
			break;
		}
	}
	if(flag == 1)
	{
		for(int i = 1;i <= n;i ++)
		printf("%d ",A[i].id);
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}