#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;

#define iter(i, n) for (int i = 1; i <= n; ++i)
#define NR 3010

vector<int> g[NR];
int a[NR];
int n;

bool dfs(int x, int fa) {
	for (int v : g[x]) if (v != fa && a[v] < a[x] && !dfs(v, x)) {
		return true;
		
	}
	return false;
}

int main() {
	scanf("%d", &n);
	iter(i, n) scanf("%d", &a[i]);
	iter(i, n - 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		g[x].push_back(y);
		g[y].push_back(x);
	}
	iter(i, n) if (dfs(i, 0)) printf("%d ", i);
	return 0;
}