#include <bits/stdc++.h>
#define f first
#define s second
#define int long long
using namespace std;
const int N = 2e5 + 69;
int n, a[N], dp[N][3], dp2[3], vis[N], dep[N], par[N];
vector<int> g[N];
void dfs(int v, int p) {
    vector<int> ch;
    par[v] = p;
    for (auto u : g[v]) {
        if (u == p)
            continue;
        dep[u] = dep[v] + 1;
        dfs(u, v);
        ch.push_back(u);
    }
    dp[v][0] = a[v];
    if (ch.empty()) {
        vis[v] = 1;
        return;
    }
    int s = 0;
    for (auto u : ch)
        s += vis[u];
    if (s > 0) {
        dp[v][2] = 1e18;
        for (auto u : ch) {
            if (vis[u])
                dp[v][1] += dp[u][0];
        }
        for (auto u : ch) {
            if (vis[u])
                continue;
            for (int j = 0;j < 3;j++)
                dp2[j] = dp[v][j];
            int s = min({dp[u][0], dp[u][1], dp[u][2]});
            dp[v][0] += s;
            dp[v][1] = min(dp2[2] + dp[u][0], dp2[1] + min({dp[u][0], dp[u][1], dp[u][2]}));
        }
    }
    else {
        dp[v][1] = 1e18;
        for (auto u : ch) {
            for (int j = 0;j < 3;j++)
                dp2[j] = dp[v][j];
            dp[v][0] += min({dp[u][0], dp[u][1], dp[u][2]});
            dp[v][1] = min(dp2[2] + dp[u][0], dp2[1] + min({dp[u][0], dp[u][1], dp[u][2]}));
            dp[v][2] += dp[u][1];
        }
    }
}
/*
void calc(int v, int p, int u, int j) {
    int x = dep[v] - dep[u];
    if (j == 0) {

    }
    else if (j == 1) {

    }
    else if (j == 2) {

    }
    for (auto u : g[v]) {
        if (u == p)
            continue;
        calc(u, v, iam);
    }
    if (v == up.back())
        up.pop_back();
}*/
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        cin >> n;
        for (int i = 1;i <= n;i++)
            cin >> a[i];
        for (int i = 1;i <= n - 1;i++) {
            int a, b;
            cin >> a >> b;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        dfs(1, 0);
        min(dp[1][1], dp[1][0]);
        vector<int> a,b;
        cout << min(dp[1][0], dp[1][1]) << '\n';
        cout << a.size() << '\n';
        for (auto u : a)
            cout << u << ' ';
        cout << '\n';
        cout << b.size() << '\n';
        for (auto u : b)
            cout << u << ' ';
    }
    return 0;
}