#include <bits/stdc++.h>
 
#ifndef aly_local
#include <ext/rope>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template<typename T>
#define oset(T) tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>
void __funxc();
#endif
using namespace std;
 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef aly_local
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

struct __time{
#ifdef aly_local
chrono::time_point<chrono::high_resolution_clock> start,end;
__time(){
start = chrono::high_resolution_clock::now();
}
~__time(){
end = chrono::high_resolution_clock::now();
chrono::duration<double,milli> duration = end-start;
cerr << "clock: " << duration.count() << " ms." << endl;
}
#endif
};
 
#define logit cerr << "i'm here" << endl;
#define invec(x) for(auto & __a : x) cin >> __a
#define outvec(x) for(auto & __a : x){cout << __a << " ";} cout << "\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define allp(x) x->begin(),x->end()
#define si(x) (int)x.size()
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define ll int64_t
#define ld long double
 
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> triplet;
 
#ifndef aly_local
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-funroll-loops")
#endif

template<typename T,typename Y>
inline void mint(T & x,Y y){
x = min<T>(x,y);}
template<typename T,typename Y>
inline void maxt(T & x,Y y){
x = max<T>(x,y);}
inline void local_input(){
#ifdef aly_local
freopen("in.txt","r",stdin);
#endif
}
constexpr int mod = (int) 998244353;
constexpr int maxn = (int) 10000;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

auto solve() -> decltype(auto) {
	int a,b;
	cin >> a >> b;

	for(int value = b;;value--){
		int range_multiples = (b/value) - ((a-1)/value);
		if(range_multiples >= 2){
			return void(cout << value << "\n");
		}
	}
	assert(false);
}

int32_t main(void){
	__time __x;
	fastio;local_input();
	uint32_t tcs = 1;
	// cin >> tcs;
	for(uint32_t i = 1;i <= tcs;i++) solve();
}

#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define ROF(i, a, b) for (ll i = (b)-1; i >= (a); --i)
#define rep(a) for (ll i = 0; i < a; ++i)

#define fio                       \
ios_base::sync_with_stdio(0); \
cin.tie(0);                   \
cout.tie(0);
#define iio \
ios_base::sync_with_stdio(0);

#define tc     \
ll tc;     \
cin >> tc; \
rep(tc)
#define vi vector<int>
#define vl vector<ll>
#define nl "\n"
#define gp " "
#define pb push_back
#define pob pop_back
#define vin(a, n)     \
vector<int> a(n); \
rep(n) cin >> a[i];
#define vln(a, n)     \
vector<ll> a(n); \
rep(n) cin >> a[i];
#define min3(a, b, c) min(min(a, b), c);
#define min4(a, b, c, d) min(min(a, b), min(c, d));
#define max3(a, b, c) max(max(a, b), c);
#define max4(a, b, c, d) max(max(a, b), max(c, d));
#define ff first
#define ss second
#define mod1 = 1000000007;
#define i1(a) ll a;cin>>a;
#define i2(a,b) ll a,b;cin>>a>>b;
#define i3(a,b,c) ll a,b;cin>>a>>b>>c;
#define i4(a,b,c,d) ll a,b;cin>>a>>b>>c>>d;
#define i5(a,b,c,d,e) ll a,b;cin>>a>>b>>c>>d>>e;


void solve()
{
}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
    #endif
    fio;
    i2(n,q);
    vln(a,n);
    vln(quer,q);
    sort(a.begin(), a.end());
    vector<ll> b(n);
    b[0]=a[0]-1;
    FOR(i,1,n){
        b[i]=a[i]-i-1;
    }
    rep(q){
        if (quer[i]>b[n-1]){
            cout<<quer[i]+n<<nl;
        }else{
            ll j=lower_bound(b.begin(),b.end(),quer[i])-b.begin();
            cout<<a[j]-(b[j]-quer[i])-1<<nl;
        }
    }
}
