#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
#include <vector> 
using namespace std; 
const int MAX_N = 3e3 + 5; 
vector<int> G[MAX_N]; 
int N, a[MAX_N]; 
int f[MAX_N]; 
void dfs(int x, int fa) { 
	f[x] = 0; 
	for ( int v : G[x]) {
		if (v == fa || a[x] <= a[v]) continue; 
		dfs(v, x); 
		if (!f[v]) f[x] = 1; 
	} 
} 
int main () { 
	scanf("%d", &N); 
	for (int i = 1; i <= N; i++) scanf("%d", a + i); 
	for (int i = 1; i < N; i++) {
		int u, v; scanf("%d %d", &u, &v); 
		G[u].push_back(v), G[v].push_back(u); 
	} 
	for (int i = 1; i <= N; i++) { 
		dfs(i, 0); 
		if (f[i]) printf("%d ", i); 
	} 
	putchar('\n'); 
    return 0; 
} 