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

const int MN = 3003;
int N, i, x, y, arr[MN], dp[MN];
vector<int> adj[MN];

void solve(int n,int p){
    dp[n]=0;
    for(auto v : adj[n]){
        if(v==p||arr[n]<=arr[v]) continue;
        solve(v, n);
        dp[n]|=(!dp[v]);
    }
}

int main(){
    for(scanf("%d",&N),i=1;i<=N;i++)
        scanf("%d",&arr[i]);
    for(i=1;i<N;i++){
        scanf("%d%d",&x,&y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    for(i=1;i<=N;i++){
        solve(i, 0);
        if(dp[i]) printf("%d ",i);
    }
    return 0;
}
