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

int arr[3005];
int memo[3005];
vector<int> adjl[3005];

int dp(int node){
if (memo[node]!=-1) return memo[node];
for (int x : adjl[node]){
    if (arr[x]<arr[node]){
        if (dp(x)==0) return memo[node] = 1;
    }
}
return memo[node] = 0;
}

int main(){
int n;
memset(memo,-1,sizeof(memo));
scanf("%d",&n);
for (int x = 0; x<n; x++){
    scanf("%d",&arr[x]);
}
for (int x = 0; x<n-1; x++){
    int a,b;
    scanf("%d%d",&a,&b);
    a--;b--;
    adjl[a].push_back(b);
    adjl[b].push_back(a);
}
for (int x = 0; x<n; x++){
    if (dp(x)==1) printf("%d ",x+1);
}
}
