#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >>n;
    vector<int> boja(n,0);
    int x=0;
    for(int i=0;i<n;i++)
    {
        cin >>x;
    }
    vector<pair<int,int> > v(n-1);
    for(int i=0;i<n-1;i++)
    {
        cin >>v[i].first>>v[i].second;
        v[i].first--;
        v[i].second--;
        if(v[i].second<v[i].first)
        {
            swap(v[i].first,v[i].second);
        }
    }
    sort(v.begin(),v.end());
    boja[v[0].first]=1;
    boja[v[0].second]=-1;


    for(int i=1;i<n-1;i++)
    {
        if(boja[v[i].second]==0)
        {
            boja[v[i].second]=boja[v[i].first]*(-1);
        }
        else
        {
            boja[v[i].first]=boja[v[i].second]*(-1);
        }
    }
    int crveni=0,plavi=0;
    for(int i=0;i<n;i++)
    {
        //cout <<boja[i]<<"\n";
        if(boja[i]==1)
        {
            crveni++;
        }
        else
        {
            plavi++;
        }
    }
    if(crveni<plavi)
    {
        cout <<crveni*x<<"\n";
        cout <<crveni<<"\n";
        for(int i=0;i<n;i++)
        {
            if(boja[i]==1)
            {
                cout <<i+1<<" ";
            }
        }
        cout <<"\n";
        cout <<0<<"\n";
    }
    else
    {
        cout <<plavi*x<<"\n";
        cout <<plavi<<"\n";
        for(int i=0;i<n;i++)
        {
            if(boja[i]==-1)
            {
                cout <<i+1<<" ";
            }
        }
        cout <<"\n";
        cout <<0<<"\n";
    }
    return 0;
}