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

const int N = 3010;
int n, a[N], g[N];
vector<int> e[N];

int dfs(int v) {
	if (g[v] >= 0) return g[v];
	g[v] = 0;
	for (int i = 0; i < (int)e[v].size(); i++) {
		int u = e[v][i];
		g[v] |= !dfs(u);
	}
	return g[v];
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		x--; y--;
		if (a[x] > a[y])
			e[x].push_back(y);
		else if (a[x] < a[y]) {
			e[y].push_back(x);
		}
	}
	fill_n(g, n, -1);
	for (int i = 0; i < n; i++) if (dfs(i)) 
		printf("%d ", i + 1);
	printf("\n");
}