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

const int N = 3005;

int n;
int a[N];
vector<int> G[N];

int dfs(int u, int p) {
	int res = 0;
	for (int v : G[u]) if (v != p) {
		int r = dfs(v, u);
		if (a[u] > a[v] && !r) res = 1;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i) cin >> a[i];
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v); G[v].push_back(u);
	}
	for (int i = 1; i <= n; ++i) {
		if (dfs(i, i)) printf("%d ", i);
	}
	printf("\n");
}