#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>ss2p;
    vector<ll>ss1c;
    vector<ll>ss2c;
    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;
    }
    ll s1=dp[1],s2=dp[2]-dp[1], d1=1, d2=2;
    ss1c.emplace_back(1);
    ss2c.emplace_back(2);
    bool indB1=false;
    bool indB2=false;
    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){
        for(int i=3; i<n+1; i++){
            if(i-d1==3) {s1+=(dp[i]-dp[i-1]); if(!indB1) ss1p.emplace_back(i); else ss1c.emplace_back(i); indB1=!indB1; d1=i;}
            if(i-d2==3) {s2+=(dp[i]-dp[i-1]); if(!indB2) ss2p.emplace_back(i); else ss2c.emplace_back(i); indB2=!indB2; d1=i;}
        }
        if(s1<s2){
            cout<<s1<<endl;
            ll cb=ss1c.size(); cout<<cb<<endl;
            for(int i=0; i<cb; i++){
                cout<<ss1c[i]<<" ";
            }
            cout<<endl;
            ll pb=ss1p.size(); cout<<pb<<endl;
            for(int i=0; i<pb; i++){
                cout<<ss1c[i]<<" ";
            }
        }
        else{
            cout<<s2<<endl;
            ll cb=ss2c.size(); cout<<cb<<endl;
            for(int i=0; i<cb; i++){
                cout<<ss2c[i]<<" ";
            }
            cout<<endl;
            ll pb=ss2p.size(); cout<<pb<<endl;
            for(int i=0; i<pb; i++){
                cout<<ss2p[i]<<" ";
            }
        }
    }
}