#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, A[3000], a, b;
vector<int>v[3000];

bool f(int x) {
	bool b = false;
	for (int i : v[x]) {
		if (A[i] < A[x] && !f(i)) {
			b = true;
		}
	}
	return b;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	for (int i = 1; i < N; ++i) {
		cin >> a >> b;
		--a;
		--b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i = 0; i < N; ++i) {
		if (f(i)) {
			cout << i + 1 << endl;
		}
	}
}