#include <bits/stdc++.h>
#define endl '\n'
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define si(a) ((ll)(a.size()))
#define fi first
#define sc second
#define here cerr<<"==============================\n"
#define llinf 100000000000000000LL
using namespace std;
#define maxn 200005
ll n;
ll a[maxn];
vector<ll> g[maxn];
ll dp[3][maxn];
ll c[maxn];
void dfs(ll u,ll p){
    c[u] = c[p]^1;
    ll mn = llinf;
    bool ok = 0;
    dp[2][u] = a[u];
    for(ll s : g[u]){
        if(s==p) continue;
        dfs(s,u);
        dp[0][u] += dp[1][s];
        dp[1][u] += min(dp[1][s],dp[2][s]);
        if(dp[2][s]<=dp[1][s]) ok = 1;
        else mn = min(mn,dp[2][s]-dp[1][s]);
        dp[2][u] += min({dp[0][s],dp[1][s],dp[2][s]});
    }
    if(si(g[u])-(u!=p)==0) dp[1][u] = llinf;
    if(!ok) dp[1][u]+=mn;
}
ll getmin(ll u){
    ll ans = llinf;
    ll j = 0;
    for(ll e = 0;e<3;e++) if(dp[e][u]<ans){ans = dp[e][u]; j = e;}
    return j;
}
vector<ll> v[2];
void dfs2(ll u,ll p,ll j){
    if(j==2){
        v[c[u]].pb(u);
        for(ll s : g[u]){
            if(s==p) continue;
            ll e = getmin(s);
            dfs2(s,u,e);
        }
        return;
    }
    if(j==1){
        vector<pll> w;
        ll mn = llinf;
        ll k = 0;
        bool ok = 0;
        for(ll s : g[u]){
            if(s==p) continue;
            if(dp[2][s]<=dp[1][s]){
                ok = 1;
                w.pb({s,2});
            }else{
                ll val = dp[2][s]-dp[1][s];
                if(val<mn){mn = val;k = s;}
                w.pb({s,1});
            }
        }
        for(pll &q : w){
            if(!ok&&q.fi==k) q.sc = 2;
            dfs2(q.fi,u,q.sc);
        }
        return;
    }
    for(ll s : g[u]){
        if(s==p) continue;
        dfs2(s,u,1);
    }
}
/**
8
1 1 1 1 1 1 1 10
1 2
1 3
2 4
2 5
3 6
3 7
7 8
**/
ll deg[maxn];
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cerr.tie(0);
    cin >> n;
    ll s = 0;
    for(ll i = 1;i<=n;i++) cin >> a[i];
    for(ll i = 1;i<=n;i++) s+=a[i];
    for(ll i = 1;i<=n-1;i++){
        ll x,y; cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
        deg[x]++;
        deg[y]++;
    }
    ll cnt = 0;
    for(ll i = 1;i<=n;i++) if(deg[i]<=1) cnt++;
    if(cnt>=n-1){
        cout<<0<<endl;
        cout<<0<<endl;
        cout<<0<<endl;
        return 0;
    }
    dfs(1,1);
    cout<<min(dp[1][1],dp[2][1])<<endl;
    ll j = 1;
    if(dp[2][1]<dp[1][1]) j = 2;
    dfs2(1,1,j);
    for(ll e = 0;e<2;e++){
        cout<<si(v[e])<<endl;
        for(ll x : v[e]) cout<<x<< " ";
        if(si(v[e])) cout<<endl;
    }
    return 0;
}