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

const int _ = 3003;
struct Edge{int end , upEd;}Ed[_ << 1];
int head[_] , cntEd , N , A[_]; bool win[_];
void addEd(int a , int b){Ed[++cntEd] = (Edge){b , head[a]}; head[a] = cntEd;}

bool getwin(int x){
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(A[Ed[i].end] < A[x] && !getwin(Ed[i].end)) return 1;
	return 0;
}

int main(){
	cin >> N; for(int i = 1 ; i <= N ; ++i) cin >> A[i];
	for(int i = 1 ; i < N ; ++i){int p , q; cin >> p >> q; addEd(p , q); addEd(q , p);}
	for(int i = 1 ; i <= N ; ++i) if(getwin(i)) cout << i << ' ';
	return 0;
}
