#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<int> tezine(n);
    vector<list<int> > graf(n + 1), najveci(n + 1);
    for(int i = 0; i < n; i++)
        cin >> tezine[i];
    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        graf[a].push_back(b);
        graf[b].push_back(a);
    }
    for(int i = 1; i <= n; i++){
        najveci[graf[i].size()].push_back(i);
    }
    vector<int> boje(n + 1, -1);
    vector<bool> posecen(n + 1, false);
    int broj_neposecenih = n;
    list<int> plave, crvene;
    for(int i = n; i >= 1; i--){
        if(najveci[i].size() == 0)
            continue;
        int boja = -2;
        for(const auto& el : najveci[i]){
            for(const auto& sused : graf[el]){
                if(!posecen[sused]){
                    posecen[sused] = true;
                    broj_neposecenih--;
                }
                boja = max(boja, boje[sused]);
            }
            if(boja <= 0){
                boje[i] = 1;
                plave.push_back(i);
            }
            else if(boja == 1){
                boje[i] = 0;
                crvene.push_back(i);
            }
            if(broj_neposecenih == 0){
                break;
            }

        }



    }
    cout << (crvene.size() + plave.size()) * tezine[0]<<endl;
    cout<<plave.size()<<endl;
    for(const auto& el : plave)
        cout<<el<<" ";
    cout<<endl;
    cout<<crvene.size()<<endl;
    for(const auto& el : crvene)
        cout<<el<<" ";

    return 0;

}