#include <bits/stdc++.h>

const int N=3010;

struct Edge{ int to,next; }way[N<<1];

int n,A[N],num[N],tot;

void Build(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot; }

void Init() {
	scanf("%d",&n);
	for (int i=1;i<=n;++i) scanf("%d",&A[i]);
	int a,b;
	for (int i=2;i<=n;++i) {
		scanf("%d%d",&a,&b);
		Build(a,b); Build(b,a);
	}
}

bool Dfs(int x,int fa) {
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (v==fa) continue;
		if (A[v]<A[x] && !Dfs(v,x)) return 1;
	}
	return 0;
}

void Solve() {
	for (int i=1;i<=n;++i) 
		if (Dfs(i,0)) printf("%d ",i);
	putchar('\n');
}

int main() {
	Init();
	Solve();
	return 0;
}