#include <bits/stdc++.h>

using namespace std;

const int MAXN = 200005;
vector<int> g[MAXN];
long long A[MAXN];

int tree_to_degenerate[MAXN];

long long dp[MAXN][2];
int sledeci[MAXN][2];

int idx = 1;
int n;

void dfs(int x, int prev) {

}

void dp_dfs(int x, int prev) {
    for (auto a: g[x]) {
        if (a != prev)
            dp_dfs(a, x);
    }

    dp[x][1] = LONG_LONG_MAX;
    dp[x][0] = 0;
    if (x == n) {
        dp[x][1] = A[x];
        sledeci[x][1] = -1;
        sledeci[x][0] = -1;
    }
    if (x + 1 <= n) {
        dp[x][0] += dp[x+1][1];
        sledeci[x][0] = x + 1;
    }
    if (x + 1 <= n) {
        long long v = A[x] + dp[x+1][0];
        if (v < dp[x][1]) {
            dp[x][1] = v;
            sledeci[x][1] = sledeci[x+1][0];
        }
    }
    if (x + 2 <= n) {
        long long v = A[x] + dp[x+2][1];
        if (v < dp[x][1]) {
            dp[x][1] = v;
            sledeci[x][1] = x+2;
        }
    }
    if (x + 3 <= n) {
        long long v = A[x] + dp[x+3][1];
        if (v < dp[x][1]) {
            dp[x][1] = v;
            sledeci[x][1] = x+3;
        }
    }
}

int main()
{
#ifdef DRZAVNO
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif // DRZAVNO
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> A[i];
        sledeci[i][0] = sledeci[i][1] = -1;
    }

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dp_dfs(1, -1);

    for (int i = 1; i <= n; i++) {

   //cout << sledeci[i][0] << " " << sledeci[i][1] << endl;
    }
    vector<int> r;
    vector<int> b;

    long long ans1 = dp[1][0];
    long long ans2 = dp[1][1];
    cout << min(ans1, ans2) << '\n';
    if (ans1 < ans2) {
        int x = sledeci[1][0];
        while(x != -1) {
            //cout << x << endl;
            if (x % 2 == 1) r.push_back(x);
            else b.push_back(x);
            x = sledeci[x][1];
        }
    }
    else {
        int x = 1;
        while(x != -1) {
            //cout << x << endl;
            if (x % 2 == 1) r.push_back(x);
            else b.push_back(x);
            x = sledeci[x][1];
        }
    }

    int s1 = r.size();
    int s2 = b.size();
    cout << s1 << '\n';
    for (int i = 0; i < s1; i++) {
        cout << r[i] << ' ';
    }
    if (s1 != 0) cout << '\n';
    cout << s2 << '\n';
    for (int i = 0; i < s2; i++) {
        cout << b[i] << ' ';
    }
    cout << '\n';


    return 0;
}