#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define MAXN 200010

using namespace std;

ll N, X, Y, sum = 0, sumA = 0, sumB = 0;
vector <ll> A(MAXN);
vector <ll> graf[MAXN];
vector <ll> par(MAXN);
vector <bool> pos(MAXN);
vector < vector <ll> > dp(3, vector <ll> (MAXN));
vector <ll> L, R;
ll D = 0;

void DFS(ll cvor, ll col)
{
    pos[cvor] = 1;
    if(col == 1) {L.push_back(cvor); sumA += A[cvor];}
    else {R.push_back(cvor); sumB += A[cvor];}
    for(auto sled : graf[cvor])
    {
        if(!pos[sled])
            DFS(sled, col^1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> N;
    for(int i = 1; i <= N; i++) {cin >> A[i]; dp[1][i] = A[i]; sum += A[i];}
    for(int i = 1; i <= N - 1; i++)
    {
        cin >> X >> Y;
        graf[X].push_back(Y);
        graf[Y].push_back(X);
    }
    if(graf[1].size() == N - 1)
    {
        if(sum - A[1] <= A[1])
        {
            cout << sum - A[1] << endl;
            cout << N - 1 << endl;
            for(int i = 2; i <= N; i++) cout << i << " ";
            cout << endl << 0 << endl;
        }
        else {cout << A[1] << endl << 1 << endl << 1 << endl << 0 << endl;}
    }
    else
    {
        DFS(1, 1);
        if(sumA < sumB)
        {
            cout << sumA << endl << L.size() << endl;
            for(auto br : L) cout << br << " ";
            cout << endl << 0 << endl;
        }
        else
        {
            cout << sumB << endl << R.size() << endl;
            for(auto br : R) cout << br << " ";
            cout << endl << 0 << endl;
        }
    }
    return 0;
}