#include <cstdio>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=3e5+5;
int n,i,j,u,v,a[N],f[N];
int En,fst[N],to[N*2],nxt[N*2];
void add(int u,int v) {
	En++; nxt[En]=fst[u]; fst[u]=En; to[En]=v;
}
void dfs(int x,int fa)
{
	int j,v;
	f[x]=0;
	for (j=fst[x];j;j=nxt[j])
		if (to[j]!=fa)
		{
			v=to[j];
			dfs(v,x);
			if (a[v]>=a[x] || f[v]) continue;
			f[x]=1;
		}
}
int main()
{
//	freopen("sidestep.in","r",stdin);
//	freopen("sidestep.out","w",stdout);
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	rep(i,1,n-1)
	{
		scanf("%d%d",&u,&v);
		add(u,v); add(v,u);
	}
	rep(i,1,n)
	{
		dfs(i,i);
		if (f[i]) printf("%d ",i);
	}
	return 0;
}