#include<bits/stdc++.h>
#define now edge[i].v
#define go(x) for(int i=head[x];i;i=edge[i].nxt)
using namespace std;
const int sz=3e3+7;
int n;
int cnt;
int u,v;
int a[sz];
bool w[sz];
int head[sz];
struct Edge{
	int v,nxt;
}edge[sz<<1]; 
void make_edge(int u,int v){
	edge[++cnt]=(Edge){v,head[u]};head[u]=cnt;
	edge[++cnt]=(Edge){u,head[v]};head[v]=cnt;
}
void dfs(int x){
	w[x]=0;
	go(x) if(a[x]>a[now]){
		dfs(now);
		if(!w[now]) w[x]=1;
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		make_edge(u,v);
	}
	for(int i=1;i<=n;i++){
		dfs(i);
		if(w[i]) printf("%d ",i);
	}
}