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

using namespace std;
typedef long long ll;

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


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";
    }/*/
    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){
        int 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 << " ";
    cout << "\n";
    cout << plavi.size() << "\n";
    for(auto u:plavi) cout << u << " ";
}