#include<bits/stdc++.h>

using namespace std;

const int   N   = 3e3 + 1;

int a[N];
int f[N];

vector<int> g[N];

int dfs(int u)  {
    int ans = 0;
    for(int v : g[u])   if (a[v] < a[u])
        ans = max(ans,dfs(v) ^ 1);
    return  ans;
}

int main()  {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int n;  cin >> n;

    for(int i = 1 ; i <= n ; ++i)   cin >> a[i];
    for(int i = 2 ; i <= n ; ++i)   {
        int x;  cin >> x;
        int y;  cin >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    int ans = 0;

    for(int i = 1 ; i <= n ; ++i)
        if (dfs(i)) cout << i << " ";
}