#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int maxn=2e5+10;

int a[maxn];
ll dp[maxn][3];
bool leaf[maxn];
bool uzeo[maxn];
int depth[maxn];
/*
0 - obojen
1 - duzine <=1
2 - duzine <=2
*/
vector<int> g[maxn];

void dfs(int node,int d=0,int p=-1){
    depth[node]=d;
    dp[node][0]=a[node];
    ll sum = 0;
    for(int i:g[node]){
        if(i==p) continue;
        dfs(i,d+1,node);

        /// 0
        dp[node][0]+=dp[i][2];
        /// 1
        sum+=dp[i][0];
    }
    dp[node][1]=min(sum,dp[node][0]);
    dp[node][2]=dp[node][1];
    for(int i:g[node]){
        if(i==p) continue;
        if(leaf[i]) continue;
        /// 2
        dp[node][2]=min(dp[node][2],sum-dp[i][0]+dp[i][1]);
    }

    /*cout<<node<<":\n";
    for(int i=0;i<3;i++) cout<<dp[node][i]<<" ";
    cout<<"\n";*/
}

void rek(int node,int vr,int dokle,int p=-1){
    if(dokle>=0){
        if(dp[node][0]==vr){
            uzeo[node]=true;
            for(int i:g[node]){
                if(i==p) continue;
                rek(i,dp[i][2],2,node);
            }
            return;
        }
    }
    if(dokle>=1){
        if(dp[node][1]==vr){
            ll sum=0;
            for(int i:g[node]){
                if(i==p) continue;
                rek(i,dp[i][0],0,node);
            }
            return;
        }
    }
    if(dokle>=2){
        if(dp[node][2]==vr){
            ll sum=0;
            for(int i:g[node]){
                if(i==p) continue;
                sum+=dp[i][0];
            }
            for(int i:g[node]){
                if(i==p) continue;
                if(leaf[i]) continue;
                if(sum-dp[i][0]+dp[i][1]==vr){
                    rek(i,dp[i][1],1,node);
                    for(int j:g[node]){
                        if(j==p) continue;
                        if(j==i) continue;
                        rek(j,dp[j][0],0,node);
                    }
                    return;
                }
            }
        }
    }
    exit(-1);
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];

    for(int i=0;i<n-1;i++){
        int u,v; cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i=1;i<=n;i++) if(g[i].size()==1) leaf[i]=true;

    ///
    for(int i=n;i>=1;i--){
        dp[i][0]=dp[i+1][2]+a[i];
        dp[i][1]=min(dp[i+1][0],dp[i][0]);
        dp[i][2]=dp[i][1];
        if(i<=n-2) dp[i][2]=min(dp[i][2],dp[i+1][1]);
    }
    cout<<dp[1][1]<<"\n";
    rek(1,dp[1][1],1);
    ///

    //dfs(1);
    //cout<<(leaf[1] ? dp[1][1]:dp[1][2])<<"\n";
    //rek(1,(leaf[1] ? dp[1][1]:dp[1][2]),(leaf[1] ? 1:2));


    vector<int> plavi;
    vector<int> crveni;
    for(int i=1;i<=n;i++){
        if(!uzeo[i]) continue;
        if(depth[i]&1) plavi.push_back(i);
        else crveni.push_back(i);
    }
    cout<<plavi.size()<<"\n";
    for(int i:plavi) cout<<i<<" ";
    if(plavi.size()!=0) cout<<"\n";
    cout<<crveni.size()<<"\n";
    for(int i:crveni) cout<<i<<" ";
    cout<<"\n";
    return 0;
}