// E - Unique Color
#include <bits/stdc++.h>
using namespace std;
#define vec vector
using vi = vec<int>;
#define rep(i,e) for(int i=0;i<(e);++i)

int n;
vi C, ans;
vec<vi> G;
map<int,int> cc;

void dfs(int v){
	if(ans[v] > 0) return;
	cc[C[v]]++;
	ans[v] = cc[C[v]];
	for(auto&u:G[v]) dfs(u);
	cc[C[v]]--;
}

int main(){
	cin>>n;
	C.resize(n);for(auto&c:C) cin>>c;

	G.resize(n);
	rep(i, n-1){
		int a, b; cin>>a>>b; --a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	ans.resize(n, -1);
	dfs(0);
	rep(i, n) if(ans[i] == 1) cout<< i+1 <<endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
// #include "atcoder/all"

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}

template <int B = 20>
struct Mex{
    vector<vector<int>> v;
    vector<int> cnt;
    Mex() : v(B), cnt(1 << B, 0){
        for(int i = 0; i < B; ++i){
            int siz = 1 << (B - i - 1);
            v[i].resize(siz);
            for(int j = 0; j < siz; ++j){
                v[i][j] = j << i;
            }
        }
    }
    void inc(int x){
        if(cnt[x]++ == 0){
            v[0][x] = (1 << (B - 1));
            for(int i = 1; i < B; ++i){
                v[i][x >> i] = min(v[i - 1][(x >> i) * 2], v[i - 1][(x >> i) * 2 + 1]);
            }
        }
    }
    void dec(int x){
        if(--cnt[x] == 0){
            v[0][x] = x;
            for(int i = 1; i < B; ++i){
                v[i][x >> i] = min(v[i - 1][(x >> i) * 2], v[i - 1][(x >> i) * 2 + 1]);
            }
        }
    }
    int get(){
        return v[B - 1][0];
    }
};

void solve(long long n, long long m, std::vector<long long> a){

    int ans = n;
    Mex<22> d;
    for(int i = 0; i < n; ++i){
        d.inc(a[i]);
        if(i >= m){
            d.dec(a[i - m]);
        }
        if(i >= m - 1){
            ans = min(ans, d.get());
        }
    }
    cout << ans << endl;
}


signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, M, std::move(A));
    return 0;
}
