#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define all(n) n.begin(),n.end()
#define forn(i,a,b) for(i=a;i<b;i++)
ll mul(ll x,ll y){  return (x*y)%mod;}
ll power(ll x, ll y) {ll res = 1; x %= mod;
 while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}
ll fact(ll n) {ll res = 1; for (ll i = 2; i <= n; i++) res = mul(res , i); return res; } 
ll nCr(ll n, ll r) { return mul(fact(n),mod_inv(mul(fact(r),fact(n - r))));} 
const int mxn =100000;
vli v[mxn];
ll c[mxn]={};
bool ans[mxn]={},vis[mxn]={};
map<int,int> m;

void dfs(ll x){
	if(m[c[x]]) ans[x]=1;
	m[c[x]]++;;
	vis[x]=1;
	ll i;
	for(i=0;i<v[x].size();i++){
       if(vis[v[x][i]]==0){
       	dfs(v[x][i]);
       }
	}
	m[c[x]]--;
}

 
int main() {
  fast;
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  ll t=1;
  // cin>>t;
  while(t--){
    ll n;
    cin>>n;
    scan(c,n);
    ll x,y,i;
    for(i=0;i<n-1;i++){
    	cin>>x>>y;
    	x--;y--;
    	v[x].pb(y);
    	v[y].pb(x);


    }
    dfs(0);
    for(i=0;i<n;i++){
    	if(!ans[i]) cout<<i+1<<endl;
    }


    
    
    
  }
return 0;    
 }  
//author : ainunsy1
#include <bits/stdc++.h>
#define forn(i,a,b) for(int i=a; i<=b; i++)
#define ford(i,a,b) for(int i=a; i>=b; i--)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
vector<ll>v[100005];
ll n,c[100005];
bool lewat[100005],ans[100005];
int udh[100005];
void dfs(ll b){
	lewat[b]=true;
	if(udh[c[b]])ans[b]=true;
	udh[c[b]]++;
	for(auto d:v[b]){
		if(!lewat[d]) dfs(d);
	}
	udh[c[b]]--;
}
void solve(){
	cin>>n;
	forn(i,1,n) cin>>c[i];
	forn(i,1,n-1){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(1);
	forn(i,1,n){
		if(!ans[i]) cout<<i<<endl;
	}
}
int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int t=1;
	// cin>>t;
	forn(i,1,t){
		solve();
	}
}