#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;

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;
    for(int i = 1; i < n; i++){
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    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;
//        cout << "c" << curr << " " << parnost.first << " " << parnost.second << endl;
        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]){
//                cout << "Ggranicni " << curr << " " << sum << " " << potrebnoboje[curr] << endl;
                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]){
            bfs.push({cvor, parnost});
        }
    }

    //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;
//        cout << "c" << curr << " " << parnost.first << " " << parnost.second << endl;
        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]){
//                cout << "Granicni " << curr << " " << sum << " " << potrebnoboje[curr] << endl;
                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});
        }
    }

    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";
    }
}