// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//


#include <iostream>
#include <vector>
#define ll long long
#define endl '\n'
using namespace std;





int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cin.tie(0);
	ll n, kb, c1, c2;
	cin >> n;
	vector<ll>dp(n + 1);
	vector<vector<ll>>graf(n + 1);
	vector<bool>pos(n + 1);
	vector<ll>ss1p;
	vector<ll>ss1c;
	dp[0] = 0;
	for (int i = 1; i < n + 1; i++) {
		cin >> kb; dp[i] = dp[i - 1] + kb;
	}
	ll br1 = 0;
	bool ind2 = false;
	for (int i = 0; i < n - 1; i++) {
		cin >> c1 >> c2;
		if (c1 == 1 || c2 == 1) br1++;
		graf[c1].emplace_back(c2);
		graf[c2].emplace_back(c1);
		if (graf[c2].size() > 2 || graf[c1].size() > 2) ind2 = true;
	}

	if (br1 == n - 1) {
		if (dp[1] <= dp[n] - dp[1]) {
			cout << dp[1] << endl;
			cout << 1 << endl;
			cout << 1 << endl;
			cout << 0 << endl;
		}
		else {
			cout << dp[n] - dp[1] << endl;
			cout << n - 1 << endl;
			for (int i = 2; i < n + 1; i++) {
				cout << i << " ";
			}
			cout << endl;
			cout << 0 << endl;
		}
	}
	else if (!ind2) {
		vector<ll>dp2(n + 1);
		dp2[0]=1000000010;
		dp2[1]=dp[1];
		dp2[2] = dp[2] - dp[1];
		for (ll i = 3; i < n + 1; i++) {
			dp2[i] = min(dp2[i-1],min(dp2[i - 3], dp2[i - 2])) + (dp[i] - dp[i - 1]);
		}
		ll z;
		bool ind=true;
		if(dp2[n]<dp2[n-1]) z=n;
		else z=n-1;
		ll i=z;
		ss1c.emplace_back(z);
		while(i>2){
            if(dp2[i]-(dp[i]-dp[i-1])==dp2[i-3]){
                if(ind) {ss1p.emplace_back(i-3); ind=!ind;}
                else {ss1c.emplace_back(i-3); ind=!ind;}
                i-=3;
            }
            else if(dp2[i]-(dp[i]-dp[i-1])==dp2[i-2]){
                if(!ind) {ss1p.emplace_back(i-2);}
                else {ss1c.emplace_back(i-2);}
                i-=2;
            }
            else{
                if(ind) {ss1p.emplace_back(i-1); ind=!ind;}
                else {ss1c.emplace_back(i-1); ind=!ind;}
                i-=1;
            }
		}
		ll bc=ss1c.size();
		ll bp=ss1p.size();
		//if(ss1c[bc-1]==3) {ss1c.emplace_back(1); bc++;}
		//if(ss1p[bp-1]==3) {ss1p.emplace_back(1); bp++;}
		cout<<dp2[z]<<endl;
        cout<<bc<<endl;
		for(int i=0; i<bc; i++){
            cout<<ss1c[i]<<" ";
		}
		cout<<endl;
		 cout<<bp<<endl;
		for(int i=0; i<bp; i++){
            cout<<ss1p[i]<<" ";
		}
	}
}