#include <bits/stdc++.h>
#define ll long long
using namespace std;
int N, u, v, X, R, B;
stack <int> RED;
stack <int> BLUE;
ll A[200096];
ll DP[4][200096];
int D[200096];
vector <int> VG[200096];
int FROM[200096];
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);
    }
    FROM[1] = 1;
    DFS(1);
//    printf("PLAV:\t\t");
//    for(int i = 1; i <= N; i++) printf(" %lld", DP[0][i]);
//    printf("\n");
//    printf("CRVEN:\t\t");
//    for(int i = 1; i <= N; i++) printf(" %lld", DP[1][i]);
//    printf("\n");
//    printf("PLAV ALI NE:\t");
//    for(int i = 1; i <= N; i++) printf(" %lld", DP[2][i]);
//    printf("\n");
//    printf("CRVEN ALI NE:\t");
//    for(int i = 1; i <= N; i++) printf(" %lld", DP[3][i]);
//    printf("\n");
    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;
}