#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=long long;
using ld=long double;
using pll=pair<ll, ll>;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
/*

*/
vector<vector<ll>> G(100010);
bool used[100010];
ll C[100010];
ll D[100010];
vector<ll> ans;

void dfs(ll v){
  used[v] = true;
  ll col = C[v];
  if (!D[col]) ans.push_back(v+1);
  D[col]++;
  for(auto nv: G[v]){
    if (used[nv]) continue;
    dfs(nv);
  }
  D[col]--;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  ll N;
  cin >> N;
  rep(i, N) cin >> C[i];
  rep(i, N-1){
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(0);
  sort(all(ans));
  for(auto v: ans)
    cout << v << endl;
}

#include <bits/stdc++.h>
using namespace std;
#define LL long long
const int M=1e5+5,P=1e9+7,base=269;
const long double e=1e-10;
inline int rd(){
	int x=0;char c=getchar();
	while(!isdigit(c))c=getchar();
	while(isdigit(c))x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x;
}
int K,n,m,p[M],ans[M];
long double A[M],B[M],C[M];
bool cmp(int x,int y){
	return C[x]>C[y]+e;
}
int main(){
	K=rd(),n=rd(),m=rd();
	int t=m;
	for(int i=1;i<=K;++i){
		A[i]=rd();p[i]=i;
		B[i]=A[i]/n*m;
		int tmp=B[i];
		t-=tmp;
		C[i]=B[i]-tmp;
		ans[i]=tmp;
	}
	sort(p+1,p+K+1,cmp);
	for(int i=1;i<=t;++i){
		ans[p[i]]++;
	}
	for(int i=1;i<=K;++i){
		printf("%d ",ans[i]);
	}
	return 0;
}
