#include <cstdio>
#include <algorithm>
#include <vector>
int a[3001], p[3001], N, f[3001];
std::vector < int > E[3001];
int main()
{
	scanf("%d", &N);
	for (int i = 1; i <= N; i++)
	{
		scanf("%d", a + i);
		p[i] = i;
	}
	std::sort(p + 1, p + N + 1, [] (int x, int y) { return a[x] < a[y]; });
	for (int i = 1, u, v; i < N; i++)
	{
		scanf("%d%d", &u, &v);
		if (a[u] > a[v])
			E[u].push_back(v);
		if (a[v] > a[u])
			E[v].push_back(u);
	}
	for (int i = 1; i <= N; i++)
		for (int j : E[p[i]])
			f[p[i]] |= !f[j];
	for (int i = 1; i <= N; i++)
		if (f[i])
			printf("%d ", i);
	puts("");
	return 0;
}
