#include <bits/stdc++.h>

using namespace std;

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

int dg_to_tree[MAXN];

long long dp[MAXN][2];
long long pravi[MAXN][2];
vector<int> sledeci[MAXN][2];
vector<int> pravi_sledeci[MAXN][2];

bool tail[MAXN];

int idx = 1;

int d[MAXN];
vector<int> vec;

void dp_dfs() {
    int n = vec.size();
    for (int i = n-2; i>=0; i--) {
        int x = vec[i];
        int x_plus_1 = (i + 1 < n) ? vec[i + 1] : -1;
        int x_plus_2 = (i + 2 < n) ? vec[i + 2] : -1;
        int x_plus_3 = (i + 3 < n) ? vec[i + 3] : -1;

        dp[x][0] = dp[x][1] = LONG_LONG_MAX;
        if (i + 1 < n) {
            long long v = dp[x_plus_1][1];;
            if (v < dp[x][0]) {
                dp[x][0] = v;
                sledeci[x][0] = {x_plus_1};
            }
        }
        if (i + 1 < n) {
            long long v = A[x] + dp[x_plus_1][0];
            if (v < dp[x][1]) {
                dp[x][1] = v;
                sledeci[x][1] = sledeci[x_plus_1][0];
            }
        }
        if (i + 1 < n) {
            long long v = A[x] + dp[x_plus_1][1];
            if (v < dp[x][1]) {
                dp[x][1] = v;
                sledeci[x][1] = {x_plus_1};
            }
        }
        if (i + 2 < n) {
            long long v = A[x] + dp[x_plus_2][1];
            if (v < dp[x][1]) {
                dp[x][1] = v;
                sledeci[x][1] = {x_plus_2};
            }
        }
        if (i + 3 < n) {
            long long v = A[x] + dp[x_plus_3][1];
            if (v < dp[x][1]) {
                dp[x][1] = v;
                sledeci[x][1] = {x_plus_3};
            }
        }
        if (pravi[x][1] > 0) {
            pravi[x][1] -= A[x];
        }
        pravi[x][0] += dp[x][0];
        pravi[x][1] += dp[x][1];
        for (auto gu: sledeci[x][0])
            pravi_sledeci[x][0].push_back(gu);
        for (auto gu: sledeci[x][1])
            pravi_sledeci[x][1].push_back(gu);
    }
}

void dfs(int x, int prev, int depth) {
    d[x] = depth;
    if (g[x].size() == 1) {
        vec.clear();
        dp[x][1] = A[x];
        dp[x][0] = 0;
        sledeci[x][1] = {-1};
        sledeci[x][0] = {-1};
        pravi[x][0] += dp[x][0];
        pravi[x][1] += dp[x][1];
    }

    for (auto a: g[x]) {
        if (a != prev) {
            dfs(a, x, depth + 1);
            vec.push_back(x);
            if (tail[x] || x == 1) {
                reverse(vec.begin(), vec.end());
                    for (auto bumbar: vec) {
                       // cout <<bumbar << " ";
                    }
                //cout << endl;
                dp_dfs();
                vec.clear();
            }
        }
    }
    dp[x][0] = pravi[x][0];
    dp[x][1] = pravi[x][1];
    sledeci[x][0] = pravi_sledeci[x][0];
    sledeci[x][1] = pravi_sledeci[x][1];

    vec.push_back(x);

}

void dfs_racvanja(int x, int prev) {
    int cnt = 0;
    for (auto a: g[x]) {
        if (a != prev) {
            dfs_racvanja(a, x);
            cnt++;
        }
    }
    if (cnt >= 2) {
         tail[x] = true;
    }
}

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);

    int n;
    cin >> n;


    for (int i = 1; i <= n; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < MAXN; i++) {
        dp[i][0] = dp[i][1] = LONG_LONG_MAX;
        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);
    dfs_racvanja(1, -1);
    dfs(1, -1, 1);
//cout << endl;
    for (int i = 1; i <= n; i++) {

        //cout << sledeci[i][0] << " " << sledeci[i][1] << endl;
        //cout << dp[i][0] << " " <<dp[i][1] << endl;
        /*
        cout << "0: ";
        for (auto gu: sledeci[i][0]) {
            cout << gu << " ";
        }
        cout << "1: ";
        for (auto gu: sledeci[i][1]) {
            cout << gu << " ";
        }
        cout << endl;
        */
    }
    //cout << 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) {
        stack<int> yay;
        for (auto gu: sledeci[1][0]) {
            yay.push(gu);
        }
        while(!yay.empty()) {
            int ururu = yay.top();
            yay.pop();
            if (sledeci[ururu][1] == vector<int>({-1})) {
                if (d[ururu] % 2 == 0) r.push_back(ururu);
                else b.push_back(ururu);
            }
            else {
                 for (auto gu: sledeci[ururu][1]) {
                    yay.push(gu);
                 }
                 if (d[ururu] % 2 == 0) r.push_back(ururu);
                 else b.push_back(ururu);
            }
        }
    }
    else {
        stack<int> yay;
        yay.push(1);
        while(!yay.empty()) {
            int ururu = yay.top();
            yay.pop();
            if (sledeci[ururu][1] == vector<int>({-1})) {
                if (d[ururu] % 2 == 0) r.push_back(ururu);
                else b.push_back(ururu);
            }
            else {
                 for (auto gu: sledeci[ururu][1]) {
                    yay.push(gu);
                 }
                 if (d[ururu] % 2 == 0) r.push_back(ururu);
                 else b.push_back(ururu);
            }
        }
    }

    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;
}