#include<bits/stdc++.h>
#define xx first
#define yy second
#define pb push_back

using namespace std;
typedef long long ll;

int n;
ll a[200010], dp[3][200010], rod[200010];
bool nivo[200010];
vector<int> graf[200010];
void dfs(int node, int par, bool nivoo) {
    rod[node]=par;
    nivo[node]=nivoo;
    for(auto adj:graf[node]) {
        if(adj==par) continue;
        dfs(adj, node, !nivoo);
    }
}
ll depe(int vr, int node) {
    if(dp[vr][node]!=-1) return dp[vr][node];
    ll suma=0LL, mini=1000000000000000LL;
    bool ok=0, usao=0;
    for(auto adj:graf[node]) {
        if(adj==rod[node]) continue;
        usao=1;
        if(vr==0) suma+=depe(1, adj);
        else if(vr==1) {
            if(depe(2, adj)<depe(1, adj)) {
                ok=1;
            }
            suma+=min(depe(1, adj), depe(2, adj));
            mini=min(mini, depe(2, adj)-depe(1, adj));
        }
        else suma+=min(min(depe(0, adj), depe(1, adj)), depe(2, adj));
        suma=min(1000000000000000LL, suma);
    }
    if(usao==0 && vr==1) suma=1000000000000000LL;
    else if(vr==1 && ok==0) suma+=mini;
    else if(vr==2) suma+=a[node];
    suma=min(1000000000000000LL, suma);
    return dp[vr][node]=suma;
}
vector<int> boja[2];
void bektrek(int vr, int node) {
    if(vr==2) {
        boja[nivo[node]].pb(node);
    }

    if(vr!=1) {
        for(auto adj:graf[node]) {
            if(adj==rod[node]) continue;
            if(vr==0) bektrek(1, adj);
            else {
                ll mini=min(min(dp[0][adj], dp[1][adj]), dp[2][adj]);
                if(mini==dp[0][adj]) bektrek(0, adj);
                else if(mini==dp[1][adj]) bektrek(1, adj);
                else bektrek(2, adj);
            }
        }
    }
    else {
        bool ok=0;
        ll mini=1000000000000000LL;
        int koji=-1;
        for(auto adj:graf[node]) {
            if(adj==rod[node]) continue;
            if(dp[2][adj]<dp[1][adj]) {
                ok=1;
                break;
            }
            if(dp[2][adj]-dp[1][adj]<mini) {
                mini=dp[2][adj]-dp[1][adj];
                koji=adj;
            }
        }
        for(auto adj:graf[node]) {
            if(adj==rod[node]) continue;
            if(ok) bektrek((dp[1][adj]<dp[2][adj] ? 1 : 2), adj);
            else if(adj==koji) bektrek(2, adj);
            else bektrek(1, adj);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i=1; i<=n; i++) {
        cin >> a[i];
        dp[0][i]=dp[1][i]=dp[2][i]=-1;
    }
    for(int i=1; i<n; i++) {
        int u, v;
        cin >> u >> v;
        graf[u].pb(v);
        graf[v].pb(u);
    }
    dfs(1, -1, 0);
    depe(2, 1); depe(1, 1); depe(0, 1);
    /*for(int i=1; i<=n; i++) {
        cout << "0: " << dp[0][i] << ' ' << " 1: " << dp[1][i] << " 2: " << dp[2][i] << endl;
    }*/
    cout << min(dp[1][1], dp[1][2]) << endl;
    bektrek((dp[1][1]<dp[1][2] ? 1 : 2), 1);
    cout << (int)boja[0].size() << endl;
    for(auto x:boja[0]) cout << x << ' ';
    cout << endl;
    cout << (int)boja[1].size() << endl;
    for(auto x:boja[1]) cout << x << ' ';
    return 0;
}
/*
15
20 4 100 15 3 15 6 3 3 1 2 4 6 3 7
1 2
1 3
1 4
2 5
2 6
4 7
4 8
4 9
6 10
6 11
6 12
7 13
13 14
13 15
*/