#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];
vector<int> g[N];
void dfs(int v, int p) {
    dep[v] = dep[p] + 1;
    for (auto u : g[v]) {
        if (u == p)
            continue;
        dfs(u, v);
    }
}
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);
        }
        if (n <= 20) {
            int bst = 1e18;
            vector<int> x, y;
            for (int mask = 1;mask < (1 << n);mask++) {
                int s = 0;
                vector<int> vis(n + 1);
                for (int i = 0;i < n;i++) {
                    if (mask >> i & 1) {
                        s += a[i + 1];
                        vis[i + 1] = 1;
                        for (auto u : g[i + 1])
                            vis[u] = 1;
                    }
                }
                int ok = 1;
                for (int i = 1;i <= n;i++)
                    ok &= (vis[i]);
                if (ok) {
                    if (bst > s) {
                        bst = s;
                        x.clear();
                        y.clear();
                        for (int i = 0;i < n;i++) {
                            if (mask >> i & 1) {
                                if (dep[i + 1] % 2 == 0)
                                    x.push_back(i + 1);
                                else
                                    y.push_back(i + 1);
                            }
                        }
                    }
                }
            }
            cout << bst << '\n';
            cout << x.size() << '\n';
            for(auto j :x)
                cout << j << ' ';
            cout << '\n';
            cout << y.size() << '\n';
            for (auto j : y)
                cout << j << '\n';
        }
        else {
        int s = a[1], s2 = 0;
        for (int j = 2;j <= n;j++)
            s2 += a[j];
        cout << min(s,s2) << '\n';
        if (s <= s2) {
            cout << 1 << '\n';
            cout << 1 << '\n';
            cout << 0 << '\n';
        }
        else {
            cout << 0 << '\n';
            cout << n - 1 << '\n';
        for (int j = 2;j <= n;j++)
            cout << j << ' ';
        }
        }

    }
    return 0;
}