#include <bits/stdc++.h>
#define maxN 200001
#define llmax 210000000000000

using namespace std;

vector<long long> a;
vector<long long> graph[maxN];
vector<pair<long long, long long> > tezine_cvorova;

int d[maxN];
long long fdp[maxN];
long long nfdp[maxN];
long long nfopdp[maxN];
long long difdp[maxN];
bool stavljen[maxN];
long long markirani[maxN];

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

    int n;

    cin >> n;
    a.push_back(0);
    for(int i = 0; i < n; i++)
    {
        int ai;
        cin >> ai;
        a.push_back(ai);
        d[i + 1] = -1;
    }

    memset(markirani, 0, sizeof(markirani));

    for(int i = 1; i < n; i++)
    {
        int u;
        int v;

        cin >> u;
        cin >> v;

        graph[u].push_back(v);
        graph[v].push_back(u);

    }

    queue<int> q;
    d[1] = 0;
    q.push(1);

    while(!q.empty())
    {
        int node = q.front();
        q.pop();

        for(int i = 0; i < graph[node].size(); i++)
        {
            if(d[graph[node][i]] == -1)
            {
                d[graph[node][i]] = d[node] + 1;
                q.push(graph[node][i]);
            }
        }
    }

    for(int i = 1; i <= n; i++)
    {
        tezine_cvorova.push_back(make_pair(d[i], i));
    }

    sort(tezine_cvorova.begin(), tezine_cvorova.end());

    for(int i = n - 1; i >= 0; i--)
    {
        int node = tezine_cvorova[i].second;

        fdp[node] = a[node];
        nfdp[node] = 0;
        nfopdp[node] = 0;

        bool lis = false;

        for(int j = 0; j < graph[node].size(); j++)
        {
            int node2 = graph[node][j];
            if(d[node2] > d[node] && graph[node2].size() == 1)
                lis = true;
        }

        int marked = -1;
        int markedsize = llmax;

        for(int j = 0; (j < graph[node].size()) && !lis; j++)
        {
            int node2 = graph[node][j];
            if(d[node2] > d[node])
            {
                if(difdp[node2] < markedsize)
                {
                    markedsize = difdp[node2];
                    marked = node2;
                }
            }
        }

        if(marked != -1)
        {
            markirani[node] = marked;
        }

        for(int j = 0; j < graph[node].size(); j++)
        {
            int node2 = graph[node][j];
            if(d[node2] > d[node])
            {
                fdp[node] += min(fdp[node2], min(nfdp[node2], nfopdp[node2]));

                if(!lis)
                {
                    if(node2 == marked)
                    {
                        nfdp[node] += fdp[node2];
                        nfopdp[node] += min(fdp[node2], nfdp[node2]);
                    }
                    else
                    {
                        nfdp[node] += min(fdp[node2], nfdp[node2]);
                        nfopdp[node] += min(fdp[node2], nfdp[node2]);
                    }
                }
                else
                {
                    if(graph[node2].size() == 1)
                    {
                        nfdp[node] += fdp[node2];
                        nfopdp[node] += fdp[node2];
                    }
                    else
                    {
                        nfdp[node] += min(fdp[node2], nfdp[node2]);
                        nfopdp[node] += min(fdp[node2], nfdp[node2]);
                    }
                }
            }

        }
        difdp[node] = fdp[node] - nfdp[node];

    }


    memset(stavljen, 0, sizeof(stavljen));

    if(min(fdp[1], nfdp[1]) == fdp[1])
    {
        stavljen[1] = true;
    }
    else
    {
        stavljen[1] = false;
    }

    vector<int> redout;
    vector<int> blueout;

    for(int i = 0; i < n; i++)
    {
        int node = tezine_cvorova[i].second;
        int tez = tezine_cvorova[i].first;

        if(stavljen[node])
        {
            if(tez % 2 == 1)
                redout.push_back(node);
            else
                blueout.push_back(node);

            for(int j = 0; j < graph[node].size(); j++)
            {
                int node2 = graph[node][j];
                if(tez < d[node2])
                {
                    if(min(fdp[node2], min(nfdp[node2], nfopdp[node2])) == fdp[node2])
                    {
                        stavljen[node2] = true;
                    }
                    else
                    {
                        stavljen[node2] = false;
                    }
                }
            }
        }
        else
        {
            for(int j = 0; j < graph[node].size(); j++)
            {
                int node2 = graph[node][j];


                if(tez < d[node2])
                {
                    if(graph[node2].size() == 1)
                    {
                        stavljen[node2] = true;
                    }
                    else
                    {
                        if(min(fdp[node2], nfdp[node2]) == fdp[node2])
                        {
                            stavljen[node2] = true;
                        }
                        else if(markirani[node] == node2 && min(fdp[node], min(nfdp[node], nfopdp[node])) == nfdp[node])
                        {
                            stavljen[node2] = true;
                        }
                        else
                        {
                            stavljen[node2] = false;
                        }
                    }


                }


            }
        }
    }

    cout << min(fdp[1], nfdp[1]) << '\n';

    cout << redout.size() << '\n';
    for(int i = 0; i < redout.size(); i++)
    {
        cout << redout[i] << " ";
    }

        cout << '\n';



    cout << blueout.size() << '\n';
    for(int i = 0; i < blueout.size(); i++)
    {
        cout << blueout[i] << " ";
    }
    cout << '\n';

    return 0;
}