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

using namespace std;

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

int d[maxN];
long long fdp[maxN];
long long nfdp[maxN];
bool stavljen[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;
    }

    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;

        for(int j = 0; j < graph[node].size(); j++)
        {
            int node2 = graph[node][j];

            if(d[node2] > d[node])
            {
                fdp[node] += min(nfdp[node2], fdp[node2]);
                if(fdp[node2] > nfdp[node2])
                {

                    bojengraf[node].push_back(make_pair(node2, 0));
                }
                else
                {
                    bojengraf[node].push_back(make_pair(node2, 1));
                }
                nfdp[node] += fdp[node2];
            }
        }
    }







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

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

    if(fdp[1] > nfdp[1])
    {
        stavljen[1] = false;
    }
    else
    {
        stavljen[1] = true;
    }
    q.push(1);

    bool prodjen[maxN];
    memset(prodjen, 0, sizeof(prodjen));


    while(!q.empty())
    {
        int node = q.front();
        q.pop();
        prodjen[node] = true;

        if(stavljen[node])
        {
            if(d[node] % 2 == 0)
            {
                redout.push_back(node);
            }
            else
            {
                blueout.push_back(node);
            }

            for(int i = 0; i < bojengraf[node].size(); i++)
            {


                if(!prodjen[bojengraf[node][i].first])
                {
                    if(bojengraf[node][i].second)
                    {
                        stavljen[bojengraf[node][i].first] = true;
                    }
                    else
                    {
                        stavljen[bojengraf[node][i].first] = false;
                    }
                    q.push(bojengraf[node][i].first);
                }

            }
        }
        else
        {
            for(int i = 0; i < bojengraf[node].size(); i++)
            {
                if(!prodjen[bojengraf[node][i].first])
                {
                    stavljen[bojengraf[node][i].first] = true;
                    q.push(bojengraf[node][i].first);
                }

            }
        }
    }

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

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


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

    return 0;
}