#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
#define maxn 200050

using namespace std;
typedef long long ll;

ll n, a[maxn], x, y, d[maxn], p[maxn], dpf[maxn], dpn[maxn], boja[maxn];
vector<ll> adj[maxn], crveni, plavi;
vector<pair<ll,ll>> dubcv;
bool bio[maxn];


vector<int> niz;
void dfs1(int v)
{
    niz.pb(v);
    for(auto u:adj[v]){
        if(u!=p[v]) dfs1(u);
    }
}


void dfs(int v)
{
    if(boja[p[v]]>0){
        if(dpf[v]<=dpn[v]){
            if(boja[p[v]]==1) boja[v]=2;
            else boja[v]=1;
        }
        else boja[v]=0;
    }
    else{
        boja[v]=boja[p[p[v]]];
    }
    for(auto u:adj[v]){
        if(u!=p[v]) dfs(u);
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i=1; i<=n; i++){
        cin >> a[i];
        boja[i]=-1;
    }
    for(int i=0; i<n-1; i++){
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    queue<int> q;
    q.push(1);
    p[1]=0;
    d[1]=0;
    while(!q.empty()){
        int s=q.front();
        q.pop();
        bio[s]=true;
        for(auto u:adj[s]){
            if(!bio[u]){
                p[u]=s;
                d[u]=d[s]+1;
                q.push(u);
            }
        }
    }
    /*/
    for(int i=1; i<=n; i++){
        cout << d[i] << " " << p[i] <<"\n";
    }/*/
    /*/
    if(d[n]==n-1){
        niz.pb(0);
        dfs1(1);
        dpf[1]=a[1]; dpn[1]=0;
        for(int i=2; i<=n; i++){
            dpf[niz[i]]=min(dpf[niz[i-1]],dpn[niz[i-1]])+a[niz[i]];
            dpn[niz[i]]=dpf[niz[i-1]];
        }
        cout << min(dpf[niz[niz.size()-1]],dpn[niz[niz.size()-1]]) << "\n";
        if(dpf[niz[niz.size()-1]]<=dpn[niz[niz.size()-1]]) boja[niz[niz.size()-1]]=1;
        else boja[niz[niz.size()-1]]=0;
        if(boja[niz[niz.size()-1]]==0) boja[niz[niz.size()-2]]=1;
        else{
            if(dpf[niz[niz.size()-2]]<=dpn[niz[niz.size()-2]]){
                    if(boja[niz[niz.size()-1]]==1) boja[niz[niz.size()-2]]=2;
                    else boja[niz[niz.size()-2]]=1;
                }
        }
        for(int i=niz.size()-3; i>=0; i--){
            if(boja[niz[i+1]]==0){
                boja[niz[i]]=boja[niz[i+2]];
            }
            else{
                if(dpf[niz[i]]<=dpn[niz[i]]){
                    if(boja[niz[i+1]]==1) boja[niz[i]]=2;
                    else boja[niz[i]]=1;
                }
                else boja[niz[i]]=0;
            }
        }
    }
    /*/

    for(int i=1; i<=n; i++){
        dubcv.pb({d[i],i});
    }
    sort(dubcv.begin(),dubcv.end());
    reverse(dubcv.begin(),dubcv.end());
    for(auto c:dubcv){
        ll v=c.se;
        dpf[v]=a[v];
        dpn[v]=0;
        for(auto u:adj[v]){
            if(u!=p[v]){
                dpn[v]+=dpf[u];
                dpf[v]+=min(dpf[u],dpn[u]);
            }
        }
    }
    cout << min(dpf[1],dpn[1]) << "\n";
    boja[0]=1;
    dfs(1);
    for(int i=1; i<=n; i++){
        if(boja[i]==1) crveni.pb(i);
        else if(boja[i]==2) plavi.pb(i);
    }
    cout << crveni.size() << "\n";
    for(auto u:crveni) cout << u << " ";
    if(crveni.size()>0) cout << "\n";
    cout << plavi.size() << "\n";
    for(auto u:plavi) cout << u << " ";
}