#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
#include <functional>
#include <time.h>
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
#define rep(i, N) for (int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define PI 3.141592653589793
const ll MOD = 1000000007;

/*clock_t start = clock();
clock_t end = clock();
const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
cout << time << endl;*/

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve(ll now,map<ll,ll> &mp){
	if(now == 1) return;
	if(now % 2 == 0){
		if(mp.find(now/2) == mp.end()){
			mp[now/2] = mp[now] + 1;
			solve(now/2,mp);
		}
		else if(mp[now/2] > mp[now] + 1){
			mp[now/2] = mp[now] + 1;
			solve(now/2,mp);
		}
	}
	else{
		ll a = now/2*2;
		if(mp.find(a/2) == mp.end()){
			mp[a/2] = mp[now] + 2;
			solve(a/2,mp);
		}
		else if(mp[a/2] > mp[now] + 2){
			mp[a/2] = mp[now] + 2;
			solve(a/2,mp);
		}
		a += 2;
		if(mp.find(a/2) == mp.end()){
			mp[a/2] = mp[now] + 2;
			solve(a/2,mp);
		}
		else if(mp[a/2] > mp[now] + 2){
			mp[a/2] = mp[now] + 2;
			solve(a/2,mp);
		}
	}
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	ll X,Y;
	cin >> X >> Y;
	map<ll,ll> mp;
	mp[Y] = 0;
	solve(Y,mp);
	ll ans = INF;
	for(auto m:mp){
		ans = min(ans,abs(m.first-X) + m.second);
	}
	cout << ans << endl;
}

#include<ctime>
#include<cstdio>
#include<cctype>
#include<algorithm>
#define ll long long
using namespace std;
const ll N=1e5+7;
ll read() {
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
struct node{
	ll i,k;
	node(ll i=0,ll k=0):i(i),k(k){}
	friend bool operator <(node a,node b){
		return a.k<b.k;
	}
}c[N];
ll n,q,cur,p,a[N],ans[N];
int main() {
	#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	q=read();
	for(ll i=1;i<=n;++i)
		a[i]=read();
	a[n+1]=5e18;
	for(ll i=1;i<=q;++i)
		c[i]=node(i,read());
	sort(c+1,c+q+1);
	for(ll i=1;i<=q;++i){
		ll qi=c[i].i;
		ll qk=c[i].k;
		while(a[p+1]-a[p]-1<qk-cur){
			cur+=a[p+1]-a[p]-1;
			++p;
		}
		ans[qi]=a[p]+qk-cur;
	}
	for(ll i=1;i<=q;++i)
		printf("%lld\n",ans[i]);
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}