#include <bits/stdc++.h>

#define int long long int
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

using namespace std;

int res = 0;
vector<int> red;

void dfs(int u,int p,int br,vector<vector<int> >& g,vector<int>& a){
    if(br%2==0){
        res+= a[u-1];
        red.push_back(u);
    }
    for(int i = 0;i<g[u].size();i++){
        if(g[u][i]!=p){
            dfs(g[u][i],u,br+1,g,a);
        }
    }
}

signed main()
{   ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a;
    for(int i = 0;i<n;i++){
        int x;
        cin >> x;
        a.push_back(x);
    }
    vector<vector<int> > g(n+1);
    for(int i = 0;i<n-1;i++){
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    bool t3 = true;
    for(int i = 1;i<=n-1;i++){
        for(int j = 0;j<g[i].size();j++){
            if(abs(g[i][j]-i)>1){
                t3 = false;
                break;
            }
        }
    }
    if(t3){
        vector<vector<int> > dp(n,vector<int>(2));
        dp[0][1] = a[0];
        dp[0][0] = 0;
        vector<int> parent(n);
        vector<int> red;
        vector<int> blue;
        parent[0] = -1;
        for(int i = 1;i<n;i++){
            dp[i][0] = dp[i-1][1];
            parent[i] = i-1;
            dp[i][1] = min(dp[i-1][0] + a[i],dp[i-1][1] + a[i]);
            if(dp[i][1]<dp[i][0]){
                if(dp[i-1][0] + a[i] < dp[i-1][1] + a[i]){
                    parent[i] = i-2;
                }
            }
        }
        cout << min(dp[n-1][1],dp[n-1][0]) << "\n";
       //cout << n << " ";
        //cout << parent[0] << endl;
       // cout << parent[n-1] << endl;
        if(dp[n-1][0]<dp[n-1][1]){
            n--;
        }
        if(n%2==0){
            red.push_back(n);
        }else{
            blue.push_back(n);
        }
        while(parent[n-1]>0){
            //cout << parent[n-1] << " ";
            int ok = parent[n-1];
           // cout << ok << endl;
            if(ok%2==0){
                red.push_back(ok);
                //cout << ok << endl;
            }else{
                blue.push_back(ok);
               // cout << ok << endl;
            }
            n = parent[n-1];
        }
        cout << red.size() << "\n";
        for(int i = 0;i<red.size();i++){
            cout << red[i] << " ";
        }
        cout << "\n";
        cout << blue.size() << "\n";
        for(int i = 0;i<blue.size();i++){
            cout << blue[i] << " ";
        }
    }
    return 0;
}