#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 10;
const long long inf = 1e18;
int n;
int a[N];
vector<int> g[N];
long long dp[N][3];  // 0 - obojim, 1 - ne obojim i resi ga sin, 2 - ne obojim i resi ga parent
vector<int> ans[2];

void dfs(int u, int par) {
    dp[u][0] = a[u];
    dp[u][2] = 0;
    long long sum = 0;
    bool ok = false;
    for(int v : g[u]) {
        if(v == par) continue;
        dfs(v, u);
        dp[u][0] += min({dp[v][0], dp[v][1], dp[v][2]});
        dp[u][2] += dp[v][1];
        sum += min(dp[v][0], dp[v][1]);
        if(dp[v][0] < dp[v][1]) ok = true;
    }
    if(!ok) {
        dp[u][1] = inf;
        for(int v : g[u]) {
            if(v == par) continue;
            dp[u][1] = min(dp[u][1], sum - dp[v][1] + dp[v][0]);
        }
    } else dp[u][1] = sum;
}

void solve(int u, int par, int force, int color) {
    if(force == 0) {
        ans[color].push_back(u);
        for(int v : g[u]) {
            if(v == par) continue;
            long long mn = min({dp[v][0], dp[v][1], dp[v][2]});
            if(mn == dp[v][0]) solve(v, u, 0, color ^ 1);
            else if(mn == dp[v][1]) solve(v, u, 1, color ^ 1);
            else solve(v, u, 2, color ^ 1);
        }
    } else if(force == 1) {
        long long sum = 0;
        bool ok = false;
        for(int v : g[u]) {
            if(v == par) continue;
            if(dp[v][0] < dp[v][1]) ok = true;
        }
        if(ok) {
            for(int v : g[u]) {
                if(v == par) continue;
                if(dp[v][0] < dp[v][1]) solve(v, u, 0, color ^ 1);
                else solve(v, u, 1, color ^ 1);
            }
        } else {
            long long mn = inf;
            int ind = -1;
            for(int v : g[u]) {
                if(v == par) continue;
                if(ind == -1 || dp[v][0] - dp[v][1] < dp[ind][0] - dp[ind][1]) {
                    mn = dp[v][0] - dp[v][1];
                    ind = v;
                }
            }
            for(int v : g[u]) {
                if(v == par) continue;
                if(v == ind) solve(v, u, 0, color ^ 1);
                else solve(v, u, 1, color ^ 1);
            }
        }
    } else {
        for(int v : g[u]) {
            if(v == par) continue;
            solve(v, u, 1, color ^ 1);
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(1, 0);
    cout << min(dp[1][0], dp[1][1]) << "\n";
    if(dp[1][0] < dp[1][1]) solve(1, 0, 0, 0);
    else solve(1, 0, 1, 0);
    long long sum = 0;
    for(int i : ans[0]) sum += a[i];
    for(int i : ans[1]) sum += a[i];
    //assert(sum == min(dp[1][0], dp[1][1]));
    cout << ans[0].size() << "\n";
    for(int i : ans[0]) cout << i << " ";
    cout << "\n" << ans[1].size() << "\n";
    for(int i : ans[1]) cout << i << " ";
    return 0;
}