#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
//nadam se da niko ne cita :))

ll n, a[200020], dp[3][200020];
vector<ll>tree[200020];
bool check[200020], colored[200020];
int last=-1;
vector<ll>red, blue;

void dfs(int v)
{
    if(check[v])return;
    check[v]=true;
    if(tree[v].size()==1 and v!=1)
    {
        dp[0][v]=0; dp[2][v]=a[v]; dp[1][v]=LONG_MAX;
        return;
    }
    ll smd=LONG_MAX;
    for(int i=0; i<tree[v].size(); i++)
    {
        if(check[tree[v][i]])continue;
        dfs(tree[v][i]);
        dp[0][v]+=dp[1][tree[v][i]];
        dp[2][v]+=min(min(dp[0][tree[v][i]], dp[1][tree[v][i]]), dp[2][tree[v][i]]);
        smd=min(dp[2][tree[v][i]]-dp[1][tree[v][i]], smd);
        dp[1][v]+=min(dp[1][tree[v][i]], dp[2][tree[v][i]]);
    }
    if(smd>0)dp[1][v]+=smd;
    dp[2][v]+=a[v];
    return;
}

void rev(int v, int c, bool lst)
{
    check[v]=true;
    if(colored[v])
    {
        if(c==1)red.push_back(v);
        else blue.push_back(v);
        for(int i=0; i<tree[v].size(); i++)
        {
            if(check[tree[v][i]])continue;
            if(dp[2][tree[v][i]]<=dp[1][tree[v][i]] and dp[2][tree[v][i]]<=dp[0][tree[v][i]])colored[tree[v][i]]=true;
        }
        for(int i=0; i<tree[v].size(); i++)
        {
            if(check[tree[v][i]])continue;
            rev(tree[v][i], (c+1)%2, 1);
        }
        return;
    }
    if(lst)
    {
        for(int i=0; i<tree[v].size(); i++)
        {
            if(check[tree[v][i]])continue;
            if(dp[2][tree[v][i]]<=dp[1][tree[v][i]])colored[tree[v][i]]=true;
        }
        for(int i=0; i<tree[v].size(); i++)
        {
            if(check[tree[v][i]])continue;
            rev(tree[v][i], (c+1)%2, 0);
        }
        return;
    }
    ll mini=LONG_MAX, pos=-1;
    for(int i=0; i<tree[v].size(); i++)
    {
        if(check[tree[v][i]])continue;
        if(mini>dp[2][tree[v][i]]-dp[1][tree[v][i]]){mini=dp[2][tree[v][i]]-dp[1][tree[v][i]]; pos=tree[v][i];}
        if(dp[2][tree[v][i]]<=dp[1][tree[v][i]]){colored[tree[v][i]]=true;}
    }
    if(mini>0)colored[pos]=true;
    for(int i=0; i<tree[v].size(); i++)
    {
        if(check[tree[v][i]])continue;
        rev(tree[v][i], (c+1)%2, 0);
    }
    return;
}

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<n; i++)
    {
        int u, v; cin>>u>>v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    dfs(1);
    cout<<min(dp[1][1], dp[2][1])<<"\n";
    for(int i=0; i<=n; i++)check[i]=false;
    if(dp[2][1]<dp[1][1]){colored[1]=true;}
    rev(1, 1, 0);
    cout<<red.size()<<"\n";
    for(int i=0; i<red.size(); i++)cout<<red[i]<<" ";
    cout<<"\n"<<blue.size()<<"\n";
    for(int i=0; i<blue.size(); i++)cout<<blue[i]<<" ";
    return 0;
}