#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
const int MAXN=2333333;
const int MAXM=2333333;
int n,a[MAXN+10],id[MAXN+10];
int fir[MAXN+10],nxt[MAXM+10],to[MAXM+10],tote;
void adde(int u,int v){to[++tote]=v;nxt[tote]=fir[u];fir[u]=tote;}
bool cmp(const int x,const int y){return a[x]<a[y];}
bool flag[MAXN+10];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%d",a+i),id[i]=i;
	for(int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),adde(u,v),adde(v,u);
	sort(id+1,id+n+1,cmp);
	for(int cc=1,u;u=id[cc],cc<=n;++cc)
	{
		for(int i=fir[u],v;v=to[i],i;i=nxt[i])
		{
			if(a[v]>=a[u])continue;
			flag[u]|=!flag[v];
		}
	}
	for(int i=1;i<=n;++i)if(flag[i])printf("%d ",i);
	return 0;
}