#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int INF=1e9;
const ll LINF=1e18;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define pb push_back

void PRINT(int x) {cerr << x;}
void PRINT(ll x) {cerr << x;}
void PRINT(double x) {cerr << x;}
void PRINT(char x) {cerr << '\'' << x << '\'';}
void PRINT(string x) {cerr << '\"' << x << '\"';}
void PRINT(bool x) {cerr << (x ? "true" : "false");}

template<typename T,typename V>
void PRINT(pair<T,V>& x){
    cerr<<"{";
    PRINT(x.fi);
    cerr<<",";
    PRINT(x.se);
    cerr<<"}";
}
template<typename T>
void PRINT(T &x){
    int id=0;
    cerr<<"{";
    for(auto _i:x){
        cerr<<(id++ ? "," : "");
        PRINT(_i);
    }
    cerr<<"}";
}
void _PRINT(){
    cerr<<"]\n";
}
template<typename Head,typename... Tail>
void _PRINT(Head h,Tail... t){
    PRINT(h);
    if(sizeof...(t)) cerr<<", ";
    _PRINT(t...);
}

#define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x)

const int mxN=2e5;

vector<ll> adj[mxN+1];
ll a[mxN+1];
ll dp[mxN+1][2][3];
int c[mxN+1];
vector<pair<int,pii>> adj1[mxN+1][2][3];
vector<int> ispis[2];

void Dfs(int u,int p){
    dp[u][0][1]=dp[u][0][2]=0;
    dp[u][1][1]=dp[u][1][2]=a[u];
    c[u]=c[p]^1;
    for(int v:adj[u]){
        if(v!=p){
            Dfs(v,u);
            dp[u][0][2]+=dp[v][0][1];  adj1[u][0][2].pb({v,{0,1}});

            ll mn=min({dp[v][1][1],dp[v][1][2],dp[v][0][1]});
            dp[u][1][2]+=min({dp[v][1][1],dp[v][1][2],dp[v][0][1]});
            if(mn==dp[v][1][1]) adj1[u][1][2].pb({v,{1,1}});
            else if(mn==dp[v][1][2]) adj1[u][1][2].pb({v,{1,2}});
            else adj1[u][1][2].pb({v,{0,1}});

            mn=min(dp[v][1][1],dp[v][1][2]);
            dp[u][0][1]+=min(dp[v][1][1],dp[v][1][2]);
            dp[u][1][1]+=min(dp[v][1][1],dp[v][1][2]);
            if(mn==dp[v][1][1]){
                adj1[u][0][1].pb({v,{1,1}});
                adj1[u][1][1].pb({v,{1,1}});
            }
            else{
                adj1[u][0][1].pb({v,{1,2}});
                adj1[u][1][1].pb({v,{1,2}});
            }
        }
    }
    /*
    Debug(u);
    Debug(dp[u][0][1],dp[u][0][2]);
    Debug(dp[u][1][1],dp[u][1][2]);
    */
}

void DfsR(int u,int b,int d){
    if(b) ispis[c[u]].pb(u);
    for(auto p:adj1[u][b][d]){
        DfsR(p.fi,p.se.fi,p.se.se);
    }
}

int main(){
    int N; cin>>N;
    for(int i=1;i<=N;i++) cin>>a[i];
    for(int i=1;i<=N-1;i++){
        int u,v; cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    Dfs(1,0);

    ll mn=min({dp[1][0][1],dp[1][0][2],dp[1][1][1],dp[1][1][2]});
    cout<<mn<<endl;
    if(mn==dp[1][0][1]) DfsR(1,0,1);
    else if(mn==dp[1][0][2]) DfsR(1,0,2);
    else if(mn==dp[1][1][1]) DfsR(1,1,1);
    else DfsR(1,1,2);
    cout<<sz(ispis[0])<<endl;
    for(int x:ispis[0]) cout<<x<<" ";
    cout<<endl;
    cout<<sz(ispis[1])<<endl;
    for(int x:ispis[1]) cout<<x<<" ";
    cout<<endl;
    return 0;
}