#include<bits/stdc++.h>
using namespace std;
const int maxN=200005;
int vr[maxN];
vector <int> v[maxN];
vector <int> crveni;
vector <int> plavi;
bool uklonjen[maxN];
int boja[maxN];
bool posecen[maxN];
void dfs(int x, int r)
{
    posecen[x]=true;
    r++;
    boja[x]=r;
    for(auto a:v[x])
    {
        if(!posecen[a])
            dfs(a,r);
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    long long suma=0;
    for(int i=1; i<=n; i++)
    {
        cin>>vr[i];
        suma+=vr[i];
    }
    for(int i=1; i<n; i++)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    if(v[1].size()==n-1)
    {
        if(suma-vr[1]>=vr[1])
        {
            cout<<vr[1]<<endl;
            cout<<1<<endl;
            cout<<1<<endl;
            cout<<0<<endl;
        }
        else
        {
            cout<<suma-vr[1]<<endl;
            cout<<n-1<<endl;
            for(int i=2; i<=n; i++)
                cout<<i<<' ';
            cout<<endl;
            cout<<0<<endl;
        }
    }
    else
    {
        dfs(1,-1);
        vector<pair<int,int>> nja;
        for(int i=1; i<=n; i++)
            nja.push_back({vr[i],i});
        sort(nja.begin(), nja.end());
        for(int i=n-1; i>=0; i--)
        {
            int indeks=nja[i].second;
            bool mozeseukloni=true;
            for(auto a:v[indeks])
            {
                bool sviuklonjeni=true;
                for(auto b:v[a])
                {
                    if(b!=indeks&&!uklonjen[b])
                        sviuklonjeni=false;
                }
                if(sviuklonjeni&&uklonjen[a])
                    mozeseukloni=false;
            }
            if(mozeseukloni)
            {
                mozeseukloni=false;
                for(auto a:v[indeks])
                {
                    if(!uklonjen[a])
                        mozeseukloni=true;
                }
            }
            if(mozeseukloni)
            {
                uklonjen[indeks]=true;
                suma-=nja[i].first;
            }
        }
        for(int i=1; i<=n; i++)
        {
            if(!uklonjen[i])
            {
                if(boja[i]%2==0)
                    crveni.push_back(i);
                else plavi.push_back(i);
            }
        }
        cout<<suma<<endl;
        cout<<crveni.size()<<endl;
        for(auto a: crveni)
            cout<<a<<" ";
        cout<<endl;
        cout<<plavi.size()<<endl;
        for(auto a: plavi)
            cout<<a<<" ";
    }
    return 0;
}