#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void izbaciVisak(vector<bool>& poseceni, ll& suma, set<int>& niz, set<int>& nizP, const vector< vector<int> >& graph, const vector<ll>& boja){
    queue<int> del;
    for(auto it = niz.begin(); it != niz.end(); it++){
        int p = *it;
//        cout << p << " ";
        bool svi = true;
        for(int i = 0; i < graph[p].size(); i++){
            if(nizP.count(graph[p][i]) == 0){
                svi = false;
                break;
            }
        }
        if(svi){
            suma -= boja[p];
            del.push(p);
        }
    }
//    cout << endl;
    while(!del.empty()){
        niz.erase(del.front());
//        cout << del.front() << " ";
        del.pop();
    }
//    cout << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
//    cin.tie(0);
    int n; cin >> n;
    vector<ll> potrebnoboje(n);
    for(int i = 0; i < n; i++) cin >> potrebnoboje[i];
    vector< vector<int> > g(n, vector<int>());
    int u, v;
    bool tcase3 = true;
    for(int i = 1; i < n; i++){
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
        if(tcase3 && u != v-1) tcase3 = false;
    }
    if(tcase3){
        vector<pair<ll, int>> dp(n+3);
        for(int i = 3; i < n+3; i++){
            ll mini = min(dp[i-3].first, min(dp[i-2].first, dp[i-1].first));
            dp[i].first = mini + potrebnoboje[i-3];
            if(mini == dp[i-1].first) dp[i].second = i-1;
            if(mini == dp[i-2].first) dp[i].second = i-2;
            if(mini == dp[i-3].first) dp[i].second = i-3;
        }
        set<int> plava, crvena;
        int i;
        ll rez;
        if(dp[n+2].first < dp[n+1].first){
            rez = dp[n+2].first;
            i = n-1;
        }else {
            rez = dp[n+1].first
            i = n-2;
            dp[n+2].first;
        }
        while(i >= 0){
            if(i%2) plava.insert(i);
            else crvena.insert(i);
            i = dp[i+3].second-3;
        }
        cout << rez << "\n";
        cout << crvena.size() << "\n";
        for(int x : crvena) cout << x+1 << " "; cout << "\n";

        cout << plava.size() << "\n";
        for(int x : plava) cout << x+1 << " "; cout << "\n";
        return 0;
    }
    vector<bool> granicniCvor(n);
    int startni = 3;
    for(int i = 0; i < n; i++){
        if(g[i].size() == 1){
            granicniCvor[ g[i][0] ] = 1;
        }
    }
    queue<pair<int, pair<bool, bool> >> bfs;

    // obilazak parnih mesta
    vector<bool> poseceni(n);
    set<int> rezParni;
    set<int> rezParniPrim;
    bfs.push({startni, {1, 1}});
    ll parnaSum = 0; // startni je ukljucen
    while(!bfs.empty()){
        int curr;
        pair<bool, bool> parnost;
        tie(curr, parnost) = bfs.front();
        bfs.pop();
        if(poseceni[curr]) continue;
        poseceni[curr] = 1;
        if(parnost.first){
            parnaSum += potrebnoboje[curr];
            if(parnost.second) rezParni.insert(curr);
            else rezParniPrim.insert(curr);
        }else{
            ll sum = 0;
            for(int cvor : g[curr]){
                if(!poseceni[cvor]){
                    sum += potrebnoboje[cvor];
                }
            }
            if(sum > potrebnoboje[curr]){
                parnaSum += potrebnoboje[curr];
                if(parnost.second) rezParniPrim.insert(curr);
                else rezParni.insert(curr);
                parnost.first = !parnost.first;
                parnost.second = !parnost.second;
            }
        }
        parnost.first = !parnost.first;
        for(int cvor : g[curr]){
//            cout << "c" << curr << " pushuje " << cvor << " " << parnost.first << " " << parnost.second << endl;
            bfs.push({cvor, parnost});
        }
    }
    izbaciVisak(poseceni, parnaSum, rezParni, rezParniPrim, g, potrebnoboje);
    izbaciVisak(poseceni, parnaSum, rezParniPrim, rezParni, g, potrebnoboje);

    //obilazak neparnih mesta
    poseceni = vector<bool>(n, 0);
    set<int> rezNeparni;
    set<int> rezNeparniPrim;
    bfs.push({startni, {0, 1}});
    ll neparnaSum = 0; // startni NIje ukljucen
    while(!bfs.empty()){
        int curr;
        pair<bool, bool> parnost;
        tie(curr, parnost) = bfs.front();
        bfs.pop();
        if(poseceni[curr]) continue;
        poseceni[curr] = 1;
        if(parnost.first){
            neparnaSum += potrebnoboje[curr];
            if(parnost.second) rezNeparni.insert(curr);
            else rezNeparniPrim.insert(curr);
        }else{
            ll sum = 0;
            for(int cvor : g[curr]){
                if(!poseceni[cvor]){
                    sum += potrebnoboje[cvor];
                }
            }
            if(sum > potrebnoboje[curr]){
                neparnaSum += potrebnoboje[curr];
                if(parnost.second) rezNeparniPrim.insert(curr);
                else rezNeparni.insert(curr);
                parnost.first = !parnost.first;
                parnost.second = !parnost.second;
            }
        }
        parnost.first = !parnost.first;
        for(int cvor : g[curr]){
            bfs.push({cvor, parnost});
        }
    }

    izbaciVisak(poseceni, neparnaSum, rezNeparni, rezNeparniPrim, g, potrebnoboje);
    izbaciVisak(poseceni, neparnaSum, rezNeparniPrim, rezNeparni, g, potrebnoboje);

    cout << min(parnaSum, neparnaSum) << "\n";
//    cout << parnaSum << " " << neparnaSum << "\n";
    if(parnaSum < neparnaSum){
        cout << rezParni.size() << "\n";
        for(int x : rezParni) cout << x+1 << " "; cout << "\n";

        cout << rezParniPrim.size() << "\n";
        for(int x : rezParniPrim) cout << x+1 << " "; cout << "\n";
    }else{
        cout << rezNeparni.size() << "\n";
        for(int x : rezNeparni) cout << x+1 << " "; cout << "\n";

        cout << rezNeparniPrim.size() << "\n";
        for(int x : rezNeparniPrim) cout << x+1 << " "; cout << "\n";
    }
}