#include <cstdio>
#define ref(i,x,y)for(int i=x;i<=y;++i)
typedef long long LL;
const int N=3001;
int n,w[N],a[N][N];
bool solve(int f,int x){
	ref(i,1,a[x][0])if(a[x][i]!=f&&w[a[x][i]]<w[x])
		if(!solve(x,a[x][i]))return 1;
	return 0;
}
int main(){
	scanf("%d",&n);
	ref(i,1,n)scanf("%d",&w[i]);
	ref(i,2,n){
		int x,y;scanf("%d%d",&x,&y);
		a[x][++a[x][0]]=y;a[y][++a[y][0]]=x;
	}
	ref(i,1,n)if(solve(0,i))printf("%d ",i);
}