#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ppll pair<ll,pair<ll,ll>>
#define pll pair<ll,ll>
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define inf 1e16
#define imin INT_MIN
#define imax INT_MAX
#define pb push_back
#define pf push_front
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
int mod =1e9+7;
bool comp(pair<int,int> a,pair<int,int> b)
{
    if(a.second == b.second) return a.first<b.first;
    return a.second<b.second;
}

void display(vll a)
{
    for(auto& val: a) cout<<val<<' ';
}

ll power(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if (b & 1) ans = (ans * a)%mod;
        a  = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

const ll N = 1e5 + 1;
ll F[N], inv[N];
void precompute(ll n)
{
    F[0] = 1;
    inv[0] = 1;
    rep(i, 1, n)
    {
        F[i] = (F[i-1] * i) % mod;
        inv[i] = power(F[i], mod - 2);
    }
}
 
bool isPrime(ll n)
{
    if(n<2) return false;
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) return false;
    }
    return true;
}
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n,q;
    cin>>n>>q;
    vll a(n);
    for(auto& val: a) cin>>val;
    sort(begin(a), end(a));
    vll b(n);
    rep(i, 0, n-1)
    {
        b[i] = a[i] - (i+1);
    }
    while(q--)
    {
        ll k;
        cin >> k;
        int idx = lower_bound(begin(b), end(b), k) - begin(b);
        if(idx < n) cout<<k + idx<<'\n';
        else {
            cout<<(k + (a[n -1] - b[n-1]))<<'\n';
        }
    }
    return 0;
}

#include"iostream"
#include"cstdio"
#include"cmath"
#include"cstring"
#include"algorithm"
#include"stack"
#include"queue"
using namespace std;

#define read(x) scanf("%d",&x)
#define readl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAXN 200005

int n,q,c;
int t,x,y;
struct  node
{
	int ls,rs,sum;
}a[MAXN*50];
int opt=0,rt[MAXN];
int fa[MAXN];

int getf(int u){return (fa[u]==u)?u:fa[u]=getf(fa[u]);}

void update(int k){a[k].sum=a[a[k].ls].sum+a[a[k].rs].sum;}

int build(int k,int l,int r,int x)
{
	if(!k) k=++opt;
	if(l==r)
	{
		a[k].sum+=1;
		return k;
	}
	int mid=(l+r)>>1;
	if(x<=mid) a[k].ls=build(a[k].ls,l,mid,x);
	else a[k].rs=build(a[k].rs,mid+1,r,x);
	return update(k),k;
}

int merge(int u,int v,int l,int r)
{
	if(!u||!v) return u|v;
	if(l==r)
	{
		a[u].sum+=a[v].sum;
		return u;
	}
	int mid=(l+r)>>1;
	a[u].ls=merge(a[u].ls,a[v].ls,l,mid);
	a[u].rs=merge(a[u].rs,a[v].rs,mid+1,r);
	return update(u),u;
}

void work(int x,int y)
{
	int u=getf(x),v=getf(y);
	if(u==v) return;
	else
	{
		fa[v]=u;
		rt[u]=merge(rt[u],rt[v],1,200000);
	}
}

int query(int k,int l,int r,int x)
{
	if(!k) return 0;
	if(l==r) return a[k].sum;
	int mid=(l+r)>>1;
	return (x<=mid)?query(a[k].ls,l,mid,x):query(a[k].rs,mid+1,r,x);
}

int main()
{
	read(n),read(q);
	for(int i=1;i<=n;i++)
	{
		read(c),fa[i]=i;
		rt[i]=build(rt[i],1,200000,c);
	}
	for(int i=1;i<=q;i++)
	{
		read(t),read(x),read(y);
		if(t==1) work(x,y);
		else
		{
			int p=getf(x);
			printf("%d\n",query(rt[p],1,200000,y));
		}
	}
	return 0;
}