#include <bits/stdc++.h>
using namespace std;
#define ref(i,x,y)for(int i=x;i<=y;++i)
const int N=3010;
vector<int> e[N];
int n,w[N],g[N];bool b[N];
void dfs(int x){
	if(b[x])return;b[x]=1;
	ref(i,0,(int)e[x].size()-1){
		int y=e[x][i];
		if(w[y]<w[x])dfs(y),g[x]|=(!g[y]);
	}
}
int main(){
	cin>>n;
	ref(i,1,n)cin>>w[i];
	ref(i,2,n){int x,y;cin>>x>>y;e[x].push_back(y);e[y].push_back(x);}
	ref(i,1,n)dfs(i),g[i]?printf("%d ",i):0;puts("");
}