#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;

int N, K, u, v, R[200500], B[200500], cntR, cntB, x;
bool f, last;
ll sum, A[200500], DP[200500], sol;
vector<int> VG[200500];
vector<int> VS[2];
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].pb(v);
        VG[v].pb(u);
        if(u != 1)
            f = 1;
    }
    if(f)
    {
        DP[0] = 1e18;
        DP[1] = A[1];
        DP[2] = A[2];
        for(int i = 3; i <= N; i++)
            DP[i] = min(DP[i - 3] + A[i], DP[i - 2] + A[i]);
        sol = min(DP[N], DP[N - 1]);
        if(DP[N] < DP[N - 1])
            x = N;
        else
            x = N - 1;
        while(x > 0)
        {
            VS[last].pb(x);
            if(DP[x - 2] < DP[x - 3])
                x -= 2;
            else
            {
                x -= 3;
                if(last)
                    last = 0;
                else
                    last = 1;
            }
        }
        printf("%lld\n", sol);
        printf("%d\n", VS[0].size());
        for(int i = 0; i < VS[0].size(); i++) printf("%d\n", VS[0][i]);
        printf("%d\n", VS[1].size());
        for(int i = 0; i < VS[1].size(); i++) printf("%d\n", VS[1][i]);
    }
    else
    {
        for(int i = 2; i <= N; i++)
        sum += A[i];
        if(sum < A[1])
        {
            printf("%lld\n", sum);
            printf("%d\n", N - 1);
            for(int i = 2; i <= N; i++)
                printf("%d\n", i);
            printf("0\n");
        }
        else
        {
            printf("%lld\n", A[1]);
            printf("1\n1\n");
            printf("0\n");
        }
    }

    return 0;
}