#include <bits/stdc++.h>
using namespace std;

const int MAXN = 3000 + 10;
int a[MAXN];
vector <int> adj[MAXN];

bool dfs(int v, int p = -1) {
	for (int i: adj[v])
		if (i != p) {
			if (a[i] >= a[v])
				continue;
			else if(!dfs(i, v))
				return true;
		}
	return false;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	for (int i = 0; i < n; i++)
		if (dfs(i))
			cout << i + 1 << ' ';
}