#include <iostream>
#include <bits/stdc++.h>

using namespace std;

struct sol{
    long long r = 0;
    vector<int> c;

    operator+=(sol d){
        r += d.r;
        for(int i = 0; i < d.c.size(); i++){
            c.push_back(d.c[i]);
        }
    }
};

sol f(int v, int t, vector<int> &a, vector<vector<int>> &b, vector<bool> &vis){
    if(b[v].size() == 1 && v != 0){
        sol t;
        t.r = 0;
        t.c = {};
        return t;
    }

    sol x;
    x.r = 0;
    x.c = {};

    bool k = true;
    for(int i = 0; i < b[v].size(); i++){
        if(!vis[b[v][i]]){
            vis[b[v][i]] = true;

            if(b[b[v][i]].size() <= 1){
                k = false;
            }

            if(t == 0){
                x += f(b[v][i], 2, a, b, vis);
                x.r += a[b[v][i]];
                x.c.push_back(b[v][i]);
            }
            else if(t == 1){
                sol x1 = f(b[v][i], 2, a, b, vis), x2 = f(b[v][i], 0, a, b, vis);
                x1.r += a[b[v][i]];
                x1.c.push_back(b[v][i]);

                if(x1.r < x2.r || k == false) x += x1;
                else x += x2;
            }
            else{
                sol x1 = f(b[v][i], 2, a, b, vis), x2 = f(b[v][i], 1, a, b, vis);
                x1.r += a[b[v][i]];
                x1.c.push_back(b[v][i]);

                if(x1.r < x2.r) x += x1;
                else x += x2;
            }

            /*if(t == 1 && k) x += f(b[v][i], 0, a, b, vis);
            if(t == 2) y += f(b[v][i], 1, a, b, vis);
            z += f(b[v][i], 2, a, b, vis);
            z.r += a[b[v][i]];
            z.c.push_back(b[v][i]);*/

            vis[b[v][i]] = false;
        }
    }

    return x;

    /*if(t == 0) return z;
    if(t == 1){
        if(x.r < z.r) return x;
        else return z;
    }
    if(y.r < z.r) return y;
    else return z;*/
}

vector<int> f2(int v, vector<vector<int>> &a){
    vector<int> s(a.size(), 0);
    s[v] = 0;

    queue<int> q;
    q.push(v);
    vector<bool> vis(a.size(), false);

    while(!q.empty()){
        int curr = q.front();
        q.pop();
        vis[curr] = true;

        for(int i = 0; i < a[curr].size(); i++){
            if(!vis[a[curr][i]]){
                vis[a[curr][i]] = true;
                q.push(a[curr][i]);
                s[a[curr][i]] = s[curr] + 1;
            }
        }
    }

    return s;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> a(n);
    vector<vector<int>> b(n, vector<int> (0));

    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    for(int i = 0; i < n-1; i++){
        int c, d;
        cin >> c >> d;
        c--; d--;

        b[c].push_back(d);
        b[d].push_back(c);
    }

    vector<bool> vis(n, false);
    vis[0] = true;
    sol x = f(0, 0, a, b, vis);
    sol y = f(0, 2, a, b, vis);
    y.r += a[0];
    y.c.push_back(0);

    vector<int> razd = f2(0, b);

    if(x.r < y.r){
        cout << x.r << endl;
        vector<int> crv(0), plv(0);
        for(int i = 0; i < x.c.size(); i++){
            if(razd[x.c[i]]%2 == 0) crv.push_back(x.c[i]);
            else plv.push_back(x.c[i]);
        }

        cout << crv.size() << endl;
        for(int i = 0; i < crv.size(); i++){
            cout << crv[i]+1 << " ";
        }
        cout << endl;
        cout << plv.size() << endl;
        for(int i = 0; i < plv.size(); i++){
            cout << plv[i]+1 << " ";
        }
        cout << endl;
    }
    else{
        cout << y.r << endl;
        vector<int> crv(0), plv(0);
        for(int i = 0; i < y.c.size(); i++){
            if(razd[y.c[i]]%2 == 0) crv.push_back(y.c[i]);
            else plv.push_back(y.c[i]);
        }

        cout << crv.size() << endl;
        for(int i = 0; i < crv.size(); i++){
            cout << crv[i]+1 << " ";
        }
        cout << endl;
        cout << plv.size() << endl;
        for(int i = 0; i < plv.size(); i++){
            cout << plv[i]+1 << " ";
        }
        cout << endl;
    }

    return 0;
}