#include <bits/stdc++.h>
using namespace std;
int n = 0, sto[3050];
int fir[3050], nxt[6050], to[6050];
bool win[3050], ans[6050];
bool dfs(int x, int fa)
{
	win[x] = false;
	for(int i = fir[x]; i; i = nxt[i])
	{
		int t = to[i];
		if(t == fa) continue;
		if(not dfs(t, x) and sto[x] > sto[t])
			win[x] = true;
	}
	return win[x];
}
signed main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%d", &sto[i]);
	for(int i = 1, j = 0; i < n; i++)
	{
		int a = 0, b = 0;
		scanf("%d%d", &a, &b);
		j++, nxt[j] = fir[a], fir[a] = j, to[j] = b;
		j++, nxt[j] = fir[b], fir[b] = j, to[j] = a;
	}
	for(int i = 1; i <= n; i++)
		ans[i] = dfs(i, 0);
	for(int i = 1; i <= n; i++)
		if(ans[i]) printf("%d ", i);
	putchar('\n');
	return 0;
}