#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> nums(n);
    auto dfs = [&](auto&& self, int x, int fa) -> int{
        int res = 1;
        for (int y : g[x]) {
            if (y != fa) {
                res += self(self, y, x);
            }
        }
        nums[x] = res;
        if (fa != -1 && a[x] == a[fa])    return res;
        return 0;
    };
    dfs(dfs, 0, -1);
    vector<int> s(n);
    s[0] = nums[0];
    auto root = [&](auto&& self, int x, int fa) -> void{
        if (fa != -1){
            if (a[fa] == a[x]){
                s[x] = s[fa];
            } else{
                s[x] = nums[x];
            }
        }
        for (int y: g[x]){
            if (y != fa){
                self(self, y, x);
            }
        }
    };
    root(root, 0, -1);
    map<int, vector<int>> cnt;
    for (int i = 0; i < n; ++i) {
        cnt[s[i]].push_back(i + 1);
    }
    vector<int> ans = cnt.rbegin()->second;
    sort(ans.begin(), ans.end());
    cout << ans.size() << '\n';
    for (int c : ans)    cout << c << ' ';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    while (T--) solve();
    return 0;
}