#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;
vector<int> red;
vector<int> blue;
int sum1 = LLONG_MAX;

void aloooooo(int sum, int idx, vector<int>& a,vector<int> color,vector<int> prvi,vector<int> drugi){
    if(idx==a.size()){
        if(sum<sum1){
            sum1 = sum;
            red = prvi;
            blue = drugi;
        }
        return;
    }
    if(idx==0){
        aloooooo(sum,idx+1,a,color,prvi,drugi);
        color[idx] = 1;
        prvi.push_back(idx+1);
        aloooooo(sum+a[idx],idx+1,a,color,prvi,drugi);
        prvi.pop_back();
        color[idx] = 0;
        color[idx] = 2;
        drugi.push_back(idx+1);
        aloooooo(sum+a[idx],idx+1,a,color,prvi,drugi);
        drugi.pop_back();
        color[idx] = 0;
    }else{
        if(color[idx-1]==0){
            color[idx] = 1;
            prvi.push_back(idx+1);
            aloooooo(sum+a[idx],idx+1,a,color,prvi,drugi);
            prvi.pop_back();
            color[idx] = 0;
            color[idx] = 2;
            drugi.push_back(idx+1);
            aloooooo(sum+a[idx],idx+1,a,color,prvi,drugi);
            drugi.pop_back();
            color[idx] = 0;
        }else{
            aloooooo(sum,idx+1,a,color,prvi,drugi);
            if(1!=color[idx-1]){
                color[idx] = 1;
                prvi.push_back(idx+1);
                aloooooo(sum+a[idx],idx+1,a,color,prvi,drugi);
                prvi.pop_back();
                color[idx] = 0;
            }
            if(2!=color[idx-1]){
                color[idx] = 2;
                drugi.push_back(idx+1);
                aloooooo(sum+a[idx],idx+1,a,color,prvi,drugi);
                drugi.pop_back();
                color[idx] = 0;
            }
        }
    }
}

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+2);
    vector<int> color(n+1,0);
    for(int i = 0;i<n-1;i++){
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> prvi;
    vector<int> drugi;
    aloooooo(0,0,a,color,prvi,drugi);
    cout << sum1 << "\n";
    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;
}