#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


int main()
{
    ios_base::sync_with_stdio(false);
//    cin.tie(0);
    int n; cin >> n;
    vector<ll> potrebnoboje(n);
    for(int i = 0; i < n; i++) cin >> potrebnoboje[i];
    vector< vector<int> > g(n, vector<int>());
    int u, v;
    bool tcase3 = true;
    for(int i = 1; i < n; i++){
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
        if(tcase3 && u != v-1) tcase3 = false;
    }
    if(true){
        vector<pair<ll, int>> dp(n+3);
        for(int i = 3; i < n+3; i++){
            ll mini = min(dp[i-3].first, min(dp[i-2].first, dp[i-1].first));
            dp[i].first = mini + potrebnoboje[i-3];
            if(mini == dp[i-1].first) dp[i].second = i-1;
            if(mini == dp[i-2].first) dp[i].second = i-2;
            if(mini == dp[i-3].first) dp[i].second = i-3;
        }
        set<int> plava, crvena;
        int i;
        ll rez;
        if(dp[n+2].first < dp[n+1].first){
            rez = dp[n+2].first;
            i = n-1;
        }else {
            rez = dp[n+1].first;
            i = n-2;
            dp[n+2].first;
        }
        while(i >= 0){
            if(i%2) plava.insert(i);
            else crvena.insert(i);
            i = dp[i+3].second-3;
        }
        cout << rez << "\n";
        cout << crvena.size() << "\n";
        for(int x : crvena) cout << x+1 << " "; cout << "\n";

        cout << plava.size() << "\n";
        for(int x : plava) cout << x+1 << " "; cout << "\n";
        return 0;
    }
}