#include <bits/stdc++.h>
#define ll long long
using namespace std;
int N, u, v, R, B;
stack <int> RED;
stack <int> BLUE;
ll X;
ll A[200096];
ll DPC[200096];
bool D[200096];
vector <int> VG[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;
    }
}
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();

    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;
}