#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAX=1e6+3;
int n, q;
ll c[MAX];
bool v[MAX];
vector<int> g[MAX];
ll deg[MAX];
ll d0[MAX], d1[MAX];
ll p0[MAX], p1[MAX];
bool drugi=true, treci=true, peti=true;

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

    cin >> n;
    for(int i=0;i<n;++i) cin >> c[i];
    for(int i=0;i<n-1;++i){
        int a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        //if(a!=1 && b!=1) drugi=false;
        deg[a]++; deg[b]++;
    }
    if(deg[0]==n-1){
        ll suma=0;
        for(int i=1;i<n;++i) suma+=c[i];
        if(suma<c[0]){
            cout << suma << '\n';
            cout << n-1 << '\n';
            for(int i=2;i<=n;++i) cout << i << ' ';
            cout << '\n' << 0 << '\n';
        }
        else{
            cout << c[0] << '\n';
            cout << 1 << '\n';
            cout << 1 << '\n';
            cout << 0 << '\n';
        }
        return 0;
    }

    d0[0]=1e15;
    d0[1]=c[0];
    d1[0]=c[0];
    d1[1]=c[1];
    for(int i=2;i<n;++i){
        d0[i]=d1[i-1];
        p0[i]=i-1;
        if(d0[i-1]<d0[i-2]){
            d1[i]=d0[i-1]+c[i];
            p1[i]=i-1;
        }
        else{
            d1[i]=d0[i-2]+c[i];
            p1[i]=i-2;
        }
    }
    vector<ll> ans1, ans2; ll tr=n-1; bool s;
    if(d1[n-1]<=d0[n-1]){
        cout << d1[n-1] << '\n';
        s=1;
    }
    else{
        cout << d0[n-1] << '\n';
        s=0;
    }
    while(tr>0){
        if(s==1){
            if(tr%2) ans1.push_back(tr);
            else ans2.push_back(tr);
        }
        if(s==1) tr=p1[tr];
        if(s==0) tr=p0[tr];
        s^=1;
    }
    if(s==1) ans2.push_back(0);

    cout << ans1.size() << '\n';
    for(auto x : ans1) cout << x+1 << ' ';
    cout << '\n';
    cout << ans2.size() << '\n';
    for(auto x : ans2) cout << x+1 << ' ';
    cout << '\n';


    return 0;
}