#include <iostream>
#include <vector>
using namespace std;

const int N = 3005;

int a[N];
int dp[N];
int par[N];
vector <int> adj[N];

void dfs(int v) {
	dp[v] = false;
	for (auto u : adj[v]) {
		if (u != par[v]) {
			par[u] = v;
			dfs(u);
			if (!dp[u] && a[u] < a[v])
				dp[v] = true;	
		}

	}
}
int main() {
	int n;
	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;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			par[j] = 0;
		}
		dfs(i);
		if (dp[i]) {
			cout << i << " ";
		}
	}
	return 0;
}