#include <bits/stdc++.h>
#define ll long long
using namespace std;
int N, u, v, R, B;
bool CHAIN = true;
stack <int> RED;
stack <int> BLUE;
ll X;
ll A[200096];
ll DPC[200096];
vector <int> VG[200096];
ll DP[4][200096];
int D[200096];
int FROM[200096];
inline void Chain()
{
    DPC[N + 1] = 1e18;
    for(int i = N; i >= 1; i--)
    {
        DPC[i] = A[i] + min(DPC[i + 2], DPC[i + 3]);
    }
    X = min(DPC[1], DPC[2]);
    for(int i = 1 + (DPC[2] == X); i <= N; i)
    {
        if(i & 1)
        {
            R++;
            RED.push(i);
        }
        else
        {
            B++;
            BLUE.push(i);
        }
        if(DPC[i + 2] < DPC[i + 3]) i += 2;
        else i += 3;
    }
}
void DFS(int node)
{
    DP[0][node] += A[node];
    DP[1][node] += A[node];
    for(int i = 0; i < VG[node].size(); i++)
    {
        if(!FROM[VG[node][i]])
        {
            FROM[VG[node][i]] = node;
            DFS(VG[node][i]);
        }
    }
    if(node != 1)
    {
        DP[0][FROM[node]] += min(DP[1][node], DP[3][node]); ///plav
        DP[1][FROM[node]] += min(DP[0][node], DP[2][node]); ///crven
        DP[2][FROM[node]] += min(DP[1][node], DP[1][node]); ///plav, ali ne bojam ga
        DP[3][FROM[node]] += min(DP[0][node], DP[0][node]); ///crven, ali ne bojam ga
    }
}
inline void BFS()
{
    int node = 1;
    queue <int> Q;
    Q.push(node);
    X = min(min(DP[0][1], DP[1][1]), min(DP[2][1], DP[3][1]));
    if(DP[0][1] == X) D[1] = 1;
    if(DP[1][1] == X) D[1] = 2;
    if(DP[2][1] == X) D[1] = 3;
    if(DP[3][1] == X) D[1] = 4;
    while(Q.size())
    {
        node = Q.front();
        if(D[node] == 1)
        {
            B++; BLUE.push(node);
        }
        else if(D[node] == 2)
        {
            R++; RED.push(node);
        }
        for(int i = 0; i < VG[node].size(); i++)
        {
            if(!D[VG[node][i]])
            {
                if(D[node] == 1)
                {
                    if(DP[1][VG[node][i]] < DP[3][VG[node][i]]) D[VG[node][i]] = 2;
                    else D[VG[node][i]] = 4;
                }
                else if(D[node] == 2)
                {
                    if(DP[0][VG[node][i]] < DP[2][VG[node][i]]) D[VG[node][i]] = 1;
                    else D[VG[node][i]] = 3;
                }
                else if(D[node] == 3) D[VG[node][i]] = 2;
                else D[VG[node][i]] = 1;
                Q.push(VG[node][i]);
            }
        }
        Q.pop();
    }
    return;
}
int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N; i++)
    {
        scanf("%lld", &A[i]);
    }
    for(int i = 1; i < N; i++)
    {
        scanf("%d %d", &u, &v);
        VG[u].push_back(v);
        VG[v].push_back(u);
        CHAIN &= v == (u + 1);
    }

    if(CHAIN) Chain();
    else
    {
        FROM[1] = 1;
        DFS(1);
        BFS();
    }

    printf("%lld\n", X);
    printf("%d\n", R);
    while(R--)
    {
        printf("%d ", RED.top());
        RED.pop();
    }
    printf("\n");
    printf("%d\n", B);
    while(B--)
    {
        printf("%d ", BLUE.top());
        BLUE.pop();
    }
    printf("\n");


    return 0;
}