#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 2*1e5 + 100;
const int long long MAX_Val = 1e12 + 100;

int n;
int long long paintArray[MAX_N];
int long long effect[MAX_N];
pair<int long long, int> segt[4 * MAX_N]; // 1. vrednost 2. index
vector<int> nodes[MAX_N];
bool solutionNodes[MAX_N];

// Za izlaz
int x = 0;
vector<int> blue;
vector<int> red;


// SEG TREE
void build(int ind=1, int l = 0, int r = n-1)
{
    if(l == r)
    {
        segt[ind].first = effect[l];
        segt[ind].second = l;
        return;
    }

    int mid = (l+r) / 2;
    build(2*ind, l, mid);
    build(2*ind + 1, mid+1, r);

    if(segt[2*ind] >= segt[2*ind+1])
    {
        segt[ind].first = segt[2*ind].first;
        segt[ind].second = segt[2*ind].second;
    }
    else
    {
        segt[ind].first = segt[2*ind+1].first;
        segt[ind].second = segt[2*ind+1].second;
    }
}

void update(int t, int v, int ind = 1, int l = 0, int r = n-1)
{
    if(l == r)
    {
        segt[ind].first -= v;
        return;
    }

    int mid = (l+r) / 2;
    if(t <= mid)
    {
        update(t,v,2*ind,l,mid);
    }
    else
    {
        update(t,v,2*ind+1,mid+1,r);
    }

    if(segt[2*ind] >= segt[2*ind+1])
    {
        segt[ind].first = segt[2*ind].first;
        segt[ind].second = segt[2*ind].second;
    }
    else
    {
        segt[ind].first = segt[2*ind+1].first;
        segt[ind].second = segt[2*ind+1].second;
    }
}

// Boji
bool bio[MAX_N];
void paint(int node, bool first)
{
    if(bio[node])
    {
        return;
    }
    bio[node] = true;

    if(solutionNodes[node])
    {
        if(first)
        {
            blue.push_back(node + 1);
        }
        else
        {
            red.push_back(node + 1);
        }
    }

    for(int i=0;i<nodes[node].size();i++)
    {
        paint(nodes[node][i], !first);
    }
}

int main()
{
    // Brz ulaz i izlaz
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    // Ulaz
    cin>>n;
    bool peti = true;
    for(int i=0;i<n;i++)
    {
        cin>>paintArray[i];

        if(paintArray[i] != paintArray[0])
        {
            peti = false;
        }
    }

    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;

        u--;
        v--;

        nodes[u].push_back(v);
        nodes[v].push_back(u);
    }

    // Obrada
    // 1 test primer
    if(n <= 20 and !peti)
    {

    }
    else
    {
        // 2 test primer
        if(nodes[0].size() == n-1)
        {
            int long long sum = 0;
            for(int i=1;i<n;i++)
            {
                sum += paintArray[i];
            }

            if(sum > paintArray[0])
            {
                x = paintArray[0];
                blue.push_back(1);
            }
            else
            {
                x = sum;
                for(int i=1;i<n;i++)
                {
                    blue.push_back(i+1);
                }
            }
        }
        else
        {
            // 5 test primer
            for(int i=0;i<n;i++)
            {
                effect[i] = nodes[i].size();
            }

            build();

            bool covered[MAX_N];
            while(segt[1].first > 0)
            {
                //cout<<segt[1].first<<" "<<segt[1].second<<endl;
                int index = segt[1].second;

                solutionNodes[index] = true;
                x += paintArray[index];

                update(index, segt[1].first);
                for(int i=0;i<nodes[index].size();i++)
                {
                    update(nodes[index][i], 1);
                }
            }

            paint(0,true);
        }
    }


    // Izlaz
    cout<<x<<endl;
    cout<<blue.size()<<endl;
    for(int i=0;i<blue.size();i++)
    {
        cout<<blue[i]<<" ";
    }cout<<endl;
    cout<<red.size()<<endl;
    for(int i=0;i<red.size();i++)
    {
        cout<<red[i]<<" ";
    }cout<<endl;

    return 0;
}