#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(data) data.begin(),data.end()
#define pb push_back
#define mp make_pair
#define INF 1e15
#define MOD 1000000007
using namespace std;
#define MAXN 200007
vector<ll> adj[MAXN],vrez;
ll a[MAXN],dp[MAXN][2][3],gp[MAXN],h[MAXN],mnv[MAXN];
void DFSh(ll u,ll p)
{
    h[u]=h[p]+1;
    for(auto v:adj[u])
    {
        if(v==p) continue;
        DFSh(v,u);
    }
}
void DFS(ll u,ll p)
{
    if(adj[u].size()==1 && adj[u][0]==p)
    {
        dp[u][0][0]=INF; dp[u][0][1]=0; dp[u][0][2]=INF;
        dp[u][1][0]=dp[u][1][1]=dp[u][1][2]=a[u];
        gp[u]=INF;
    }
    else
    {
        for(auto v:adj[u])
        {
            if(v==p) continue;
            DFS(v,u);
        }
        dp[u][1][0]=dp[u][1][1]=dp[u][1][2]=a[u];
        dp[u][0][0]=INF;
        mnv[u]=INF;
        for(auto v:adj[u])
        {
            if(v==p) continue;
            gp[u]+=dp[v][1][0];
            //dp[u][0][0]+=dp[v][1][0];
            dp[u][0][1]+=min(dp[v][0][0],dp[v][1][0]);
            dp[u][0][2]+=min(dp[v][1][0],gp[v]);
            mnv[u]=min(mnv[u],dp[v][1][0]-min(dp[v][1][0],gp[v]));
            dp[u][1][0]+=min(dp[v][0][1],dp[v][1][1]);
            dp[u][1][1]+=min(dp[v][0][1],dp[v][1][1]);
            dp[u][1][2]+=min(dp[v][0][1],dp[v][1][1]);
        }
        dp[u][0][2]+=mnv[u];
    }
}
void DFS1(ll u,ll p,ll i,ll j,bool preskoci)// dp[u][i][j]
{
    if(preskoci)
    {
        for(auto v:adj[u])
        {
            if(v==p) continue;
            DFS1(v,u,1,0,false);
        }
    }
    else
    {
        if(i==0 && j==0)
        {
            for(auto v:adj[u])
            {
                if(v==p) continue;
                DFS1(v,u,1,0,false);
            }
        }
        else if(i==0 && j==1)
        {
            for(auto v:adj[u])
            {
                if(v==p) continue;
                if(dp[v][0][0]<dp[v][1][0]) DFS1(v,u,0,0,false);
                else DFS1(v,u,1,0,false);
            }
        }
        else if(i==0 && j==2)
        {
            ll idx=-1;
            for(auto v:adj[u])
            {
                if(v==p) continue;
                if(dp[v][1][0]-min(dp[v][1][0],gp[v])==mnv[u]) {idx=v; break;}
            }
            for(auto v:adj[u])
            {
                if(v==p) continue;
                if(v==idx) DFS1(v,u,1,0,false);
                else if(dp[v][1][0]<gp[v]) DFS1(v,u,1,0,false);
                else DFS1(v,u,0,0,true);
            }
        }
        else if(i==1)
        {
            vrez.pb(u);
            for(auto v:adj[u])
            {
                if(v==p) continue;
                if(dp[v][0][1]<dp[v][1][1]) DFS1(v,u,0,1,false);
                else DFS1(v,u,1,1,false);
            }
        }
    }
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,uu,vv,rez=0,rt=0; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<n;i++)
    {
        cin>>uu>>vv;
        adj[uu].pb(vv); adj[vv].pb(uu);
    }
    DFS(1,0); DFSh(1,0);
    rez=min(dp[1][0][2],dp[1][1][2]);
    cout<<rez<<endl;
    if(dp[1][0][2]<dp[1][1][2]) DFS1(1,0,0,2,false);
    else DFS1(1,0,1,2,false);
    vector<ll> vvv[2];
    for(auto mm:vrez) vvv[h[mm]%2].pb(mm);
    cout<<vvv[0].size()<<endl;
    for(auto mm:vvv[0]) cout<<mm<<" "; cout<<endl;
    cout<<vvv[1].size()<<endl;
    for(auto mm:vvv[1]) cout<<mm<<" "; cout<<endl;
    return 0;
}