output_description: Print the indices of the vertices v such that Takahashi can place the piece on
  v at the beginning and win the game, in a line, in ascending order.
  
  * * *
input_description: The input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 … A_N
      a_1 b_1
      :
      a_{N-1} b_{N-1}
attempt: #include <bits/stdc++.h>
  //#include <math.h>
  using namespace std;
  
  #define INF 1.1e9
  #define LINF 1.1e18
  #define FOR(i,a,b) for (int i=(a);i<(b);++i)
  #define REP(i,n) FOR(i,0,n)
  #define ALL(v) (v).begin(),(v).end()
  #define pb push_back
  #define pf push_front
  #define fi first
  #define se second
  #define BIT(x,n) bitset<n>(x)
  #define PI 3.14159265358979323846
  
  typedef long long ll;
  typedef pair<int,int> P;
  typedef pair<ll,P> PP;
  
  //-----------------------------------------------------------------------------
  
  int n;
  vector<int> g[3000];
  ll a[3000];
  int dp[3000];
  
  int dfs(int v,int prv) {
  	if(dp[v]!=0) return dp[v];
  	for(auto u:g[v]) {
  		if(u!=prv&&a[u]<a[v]&&dfs(u,v)==-1) return dp[v]=1;
  	}
  	return dp[v]=-1;
  }
  
  int main() {
  	cin.tie(0);
  	ios::sync_with_stdio(false);
  
  	cin>>n;
  	REP(i,n) cin>>a[i];
  	REP(i,n-1) {
  		int u,v;cin>>u>>v;;u--,v--;
  		g[u].pb(v),g[v].pb(u);
  	}
  	REP(i,n) {
  		dfs(i,-1);
  	}
  	bool fst=true;
  	REP(i,n) {
  		if(!fst) cout<<' ';
  		if(dp[i]==1) {
  			cout<<i+1;
  			fst=false;
  		}
  	}
  	cout<<endl;
  
  	return 0;
  }
  
problem_description: Statement
  
  There is a tree with N vertices, numbered 1 through N. The i-th of the N-1
  edges connects vertices a_i and b_i.
  
  Currently, there are A_i stones placed on vertex i. Takahashi and Aoki will
  play a game using this tree.
  
  First, Takahashi will select a vertex and place a piece on it. Then, starting
  from Takahashi, they will alternately perform the following operation:
  
    * Remove one stone from the vertex currently occupied by the piece.
    * Then, move the piece to a vertex that is adjacent to the currently occupied vertex.
  
  The player who is left with no stone on the vertex occupied by the piece and
  thus cannot perform the operation, loses the game. Find all the vertices v
  such that Takahashi can place the piece on v at the beginning and win the
  game.
samples: [{"input": "3\n    1 2 3\n    1 2\n    2 3", "output": "2\n    \n\nThe following is one possible progress of the game when Takahashi places the\npiece on vertex 2:\n\n  * Takahashi moves the piece to vertex 1. The number of the stones on each vertex is now: (1,1,3).\n  * Aoki moves the piece to vertex 2. The number of the stones on each vertex is now: (0,1,3).\n  * Takahashi moves the piece to vertex 1. The number of the stones on each vertex is now: (0,0,3).\n  * Aoki cannot take a stone from the vertex, and thus Takahashi wins.\n\n* * *"}, {"input": "5\n    5 4 1 2 3\n    1 2\n    1 3\n    2 4\n    2 5", "output": "1 2\n    \n\n* * *"}, {"input": "3\n    1 1 1\n    1 2\n    2 3", "output": "Note that the correct output may be an empty line."}]