#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define fi first
#define si second
#define pii pair<int,int>

using namespace std;

const int maxn=2*1e5+10;

int parent[maxn];
vector<int>graf[maxn];
vector<int>niz(maxn);

int main()
{
    speed;
    bool sluc2=1,sluc3=1;
    int n;
    int sum1=0,sumall=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>niz[i];
        sumall+=niz[i];
        if(i!=0&&niz[i]!=niz[i-1])sluc3=0;
    }
    for(int i=1;i<n;i++){
        int u,v;
        cin>>u>>v;
        if(u+1!=v)sluc2=0;
        graf[u].push_back(v);
        graf[v].push_back(u);
    }
    if(graf[1].size()==n-1){
        sum1=niz[1];
        for(int i=1;i<n;i++){
            int u,v;
            cin>>u>>v;
        }
        if(sum1<=sumall-sum1){
            cout<<sum1<<endl;
            cout<<1<<endl<<1<<endl<<0<<endl;
        }
        else{
            cout<<sumall-sum1<<endl;
            cout<<n-1<<endl;
            for(int i=2;i<=n;i++)cout<<i<<" ";
            cout<<endl<<0<<endl;
        }
    }
    else if(sluc2){
        bool r=true;
        unordered_map<int,bool>col;
        vector<int>dp(n+1,0);
        dp[1]=niz[1];
        for(int i=2;i<=n;i++){
            if(dp[i-1]<dp[i-2]){
                if(r)col[i]=false;
                else col[i]=true;
                r=!r;
                parent[i]=i-1;
                dp[i]=dp[i-1]+niz[i];
            }
            else{
                col[i]=r;
                parent[i]=i-2;
                dp[i]=dp[i-2]+niz[i];
            }
        }
        vector<int>red,blue;
        if(dp[n]<dp[n-1]){
            cout<<dp[n]<<endl;
            int nod=n;
            while(parent[nod]!=0){
                if(col[nod])red.push_back(nod);
                else blue.push_back(nod);
                nod=parent[nod];
            }
            if(col[nod])red.push_back(nod);
            else blue.push_back(nod);
            reverse(all(red));
            reverse(all(blue));
            cout<<red.size()<<endl;
            for(auto i:red)cout<<i<<" ";
            cout<<endl<<blue.size()<<endl;
            for(auto i:blue)cout<<i<<" ";
        }
        else{
            cout<<dp[n-1]<<endl;
            int nod=n-1;
            while(parent[nod]!=0){
                if(col[nod])red.push_back(nod);
                else blue.push_back(nod);
                nod=parent[nod];
            }
            if(col[nod])red.push_back(nod);
            else blue.push_back(nod);
            reverse(all(red));
            reverse(all(blue));
            cout<<red.size()<<endl;
            for(auto i:red)cout<<i<<" ";
            cout<<endl<<blue.size()<<endl;
            for(auto i:blue)cout<<i<<" ";
        }
    }
    else if(sluc3){
        return 0;
    }

    return 0;
}