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

#define rep(i, a, n) for(int i=(a); i<(n); ++i)
#define per(i, a, n) for(int i=(a); i>(n); --i)
#define pb emplace_back
#define mp make_pair
#define clr(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(),(x).end()
#define lowbit(x) (x & -x)
#define fi first
#define se second
#define lson o<<1
#define rson o<<1|1
#define gmid l[o]+r[o]>>1
 
using LL = long long;
using ULL = unsigned long long;
using pii = pair<int,int>;
using PLL = pair<LL, LL>;
using UI = unsigned int;
 
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1.0);

const int N = 1e5 + 10;

int n, Q;
LL a[N], k;

LL query(){
	int low = 0, top = n, mid, ans = 0;
	while(low <= top){
		mid = low + top >> 1;
		if(a[mid] - mid >= k){
			top = mid - 1;
		} else {
			ans = max(ans, mid);
			low = mid + 1;
		}
	}
	return k + ans;
}

int main(){
	scanf("%d %d", &n, &Q);
	a[0] = 0;
	rep(i, 1, n + 1)	scanf("%lld", a+i);
	while(Q--){
		scanf("%lld", &k);
		if(k <= a[n] - n){
			printf("%lld\n", query());
		} else {
			printf("%lld\n", k + n);
		}
	}
	return 0;
}

// KNOW NOTHING!
#include <bits/stdc++.h>
#define ll long long int
#define F(i,j,k,in) for(int i=j;i<k;i+=in)
#define DF(i,j,k,in) for(int i=j;i>=k;i-=in)
#define feach(it,l) for (auto it = l.begin(); it != l.end(); ++it)
#define fall(a) a.begin(),a.end()
#define sz(x) (int)x.size()
#define szs(x) (int)x.length()
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define eq equal_range
#define fs first
#define ss second
#define ins insert
#define mkp make_pair
#define endl "\n"
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vin;
typedef vector<char> vch;
typedef vector<string> vst;
typedef set<ll> sll;
typedef set<int> sint;
typedef set<char> sch;
typedef set<string> sst;
typedef queue<ll> qll;
typedef queue<int> qin;
typedef deque<ll> dqll;
typedef deque<int> dqint;
typedef priority_queue<ll> pqll;
typedef priority_queue<int> pqin;
typedef map<ll,ll> mpll;
typedef map<int,int> mpin;
typedef pair<ll,ll> pll;
typedef pair<int,int> pin;
const ll MOD=1000000007;
const long double PI=3.1415926535897932384626433832795;
ll pwr(ll b,ll p){ll res=1;while(p){if(p&1) {res*=b; p--;}else{b*=b; p>>=1;}}return res;}
ll mpwr(ll b,ll p){ll res=1;while(p){if(p&1) {res=(res*b)%MOD; p--;}else{b=(b*b)%MOD; p>>=1;}}return res;}
int msb (int n) {return 31-__builtin_clz(n);}
ll msbl (ll n) {return 63-__builtin_clzll(n);}
int lsb (int n) {return __builtin_ctz(n);}
ll  lsbl (ll n) {return __builtin_ctzll(n);}
int setbit (int n) {return __builtin_popcount(n);}
ll setbitl (ll n) {return __builtin_popcountll(n);}
const int maxn = 1e5+10;
vin adj [maxn];
int c[maxn];
int vis [maxn];
mpin mp;
int n;
sint good;
void dfs (int u) {
	//cout<<u<<" "<<c[u]<<" "<<mp[c[u]]<<endl;
	if (mp[c[u]]==0) good.ins(u);
	++mp[c[u]];
	vis [u]=1;
	for (auto v : adj[u]) {
		if (vis[v]==0) dfs (v);
	}
	if (mp[c[u]]>0) --mp[c[u]];
}
int main()
{
/*
freopen ("input.txt","r","stdin");
freopen ("output.txt","w","stdout");
*/
ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);
cin>>n;
F (i,0,n,1) cin>>c[i];
F (i,0,n-1,1) {
	int a, b; cin>>a>>b;
	--a ; --b;
	adj[a].pb (b); adj[b].pb(a);
}
dfs (0);
for (auto e : good) cout<<e+1<<endl;
return 0;
}
/* What we know is a drop , but what we don't know is an ocean !*/ 	