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

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);
    }
    vector<int> color;
    vector<int> dp(n);
    dp[0] = a[0];
    dp[1] = a[1];
    vector<int> parent(n);
    for(int i = 2;i<n;i++){
        dp[i] = min(dp[i-1],dp[i-2]) + a[i];
        if(dp[i-1]<dp[i-2]){
            parent[i] = i-1;
        }else{
            parent[i] = i-2;
        }
    }
    cout << min(min(dp[n-1],dp[n-2]),dp[n-3]) << "\n";
    n--;
    if(dp[n]>dp[n-1] && dp[n-1]<dp[n-2]){
        n--;
    }
    if(dp[n-2]<dp[n] && dp[n-2]<dp[n-1]){
        n-=2;
    }
    vector<int> red;
    vector<int> blue;
    if(n%2==0){
        red.push_back(n+1);
    }else{
        blue.push_back(n+1);
    }
    while(parent[n]!=0 && parent[n]!=1){
        int ok = parent[n];
        if(ok%2==0){
            red.push_back(ok+1);
        }else{
            blue.push_back(ok+1);
        }
        n = parent[n];
    }
    if(parent[n]==0){
        red.push_back(1);
    }else{
        blue.push_back(2);
    }
    cout << red.size() << "\n";
    for(int i = 0;i<red.size();i++){
        cout << red[i] << " ";
    }
    if(red.size()>0){
        cout << "\n";
    }
    cout << blue.size() << "\n";
    for(int i = 0;i<blue.size();i++){
        cout << blue[i] << " ";
    }
    return 0;
}