#include <bits/stdc++.h>

#define int long long int
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

using namespace std;

int res = 0;
vector<int> red;

void dfs(int u,int p,int br,vector<vector<int> >& g,vector<int>& a){
    if(br%2==0){
        res+= a[u-1];
        red.push_back(u);
    }
    for(int i = 0;i<g[u].size();i++){
        if(g[u][i]!=p){
            dfs(g[u][i],u,br+1,g,a);
        }
    }
}

signed main()
{   ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a;
    for(int i = 0;i<n;i++){
        int x;
        cin >> x;
        a.push_back(x);
    }
    vector<vector<int> > g(n+1);
    for(int i = 0;i<n-1;i++){
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1,-1,0,g,a);
    int idk = res;
    vector<int> nzm;
    nzm = red;
    res = 0;
    red.clear();
    dfs(g[1][0],-1,0,g,a);
    if(res<idk){
        nzm = red;
    }
    idk = min(idk,res);
    cout << res << "\n";
    cout << red.size() << "\n";
    for(int i = 0;i<red.size();i++){
        cout << red[i] << " ";
    }
    cout << "\n";
    cout << 0;
    return 0;
}