#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define li(i,a,b) for(int (i) = (a); (i)<(b); i++)
#define all(v) v.begin(), v.end()
#define mem(name, val) memset(name, val, sizeof(name))
#define endl '\n'

const int nmax = 200005;
vector<int> adj[nmax];
int cost[nmax];

vector<ll> memo0(nmax,0), memo1(nmax,0);

vector<int> boja(nmax,0);
vector<int> crvena;
vector<int> plava;

ll dp(bool isColored, int parent, int i){

    ll res = 0;
    if(isColored){
        if(memo1[i] != 0) return memo1[i];
        for(int ch: adj[i]){
            if(ch == parent) continue;
            res += min(dp(false, i, ch), dp(true, i ,ch));
        }
        res+=cost[i];
        memo1[i] = res;
        return res;
    }
    else{
        if(memo0[i] != 0) return memo0[i];
        for(int ch: adj[i]){
            if(ch == parent) continue;
            res += dp(true, i, ch);
        }
        memo0[i] = res;
        return res;
    }
}

void bfs(int parent, int i){

    if(boja[parent] != 0){
        if(memo0[i]>memo1[i]){
            if(boja[parent] == 1){
                boja[i] = -1;
                plava.push_back(i);
            } 
            else if(boja[parent] == -1){
                crvena.push_back(i);
                boja[i] = 1;
            }
        }
    }
    else{
        boja[i] = 1;
        crvena.push_back(i);
    }

    for(int ch: adj[i]){
        if(ch == parent) continue;

        bfs(i, ch);
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n;
    cin>>n;
    li(i,1,n+1) cin>>cost[i];

    int u, v;
    li(i,0,n-1){
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    cout<<min(dp(false, -1, 1), dp(true,-1, 1))<<endl;

    // 1 crvena 0 nista -1 plava
    if(memo1[1] < memo0[1]){
        boja[1] = -1;
        plava.push_back(1);
    }

    bfs(-1, 1);

    cout<<crvena.size()<<endl;
    for(int g : crvena){
        cout<<g<<" ";
    }
    cout<<endl;
    cout<<plava.size()<<endl;
    for(int g: plava){
        cout<<g<<" ";
    }
    cout<<endl;

    return 0;
}