//HovalHaq!
#include <bits/stdc++.h>
using namespace std;
const int maxN = 1 << 12;

struct node {
	int c = 0;
	vector<int> N;
} G[maxN];

bool DFS(int v, int w) {
	bool win = false;
	for(int u : G[v].N) if(u != w) {
		bool s = DFS(u, v);
		if(G[u].c < G[v].c && !s)
			win = true;
	}
//	cout << v << " " << win << "\n";
	return win;
}

int main() {
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> G[i].c;
	for(int i = 1; i < n; i++) {
		int u, v; cin >> u >> v;
		u--, v--;
		G[u].N.push_back(v);
		G[v].N.push_back(u);
	}
	for(int i = 0; i < n; i++) {
//		cout << i << "\n";
		if(DFS(i, -1)) cout << i + 1 << " ";
	}
}
