#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
//nadam se da niko ne cita :))

ll n, a[200020];
vector<ll>tree[200020];
bool st1=true, st2=true;

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<n; i++)
    {
        int u, v; cin>>u>>v;
        tree[u].push_back(v);
        tree[v].push_back(u);
        if(u!=1 and v!=1)st1=false;
        if(u!=v+1 and v!=u+1)st2=false;
    }
    if(st1)
    {
        ll sum=0;
        for(int i=2; i<=n; i++)sum+=a[i];
        if(sum>=a[1])
        {
            cout<<a[1]<<"\n"<<1<<"\n"<<1<<"\n"<<0;
            return 0;
        }
        cout<<sum<<"\n"<<n-1<<"\n";
        for(int i=2; i<=2; i++)cout<<i<<" ";
        cout<<"\n0";
        return 0;
    }
    if(st2)
    {
        ll s1=0, s2=0;
        for(int i=1; i<=n; i++)
        {
            if(i%2==0)s1+=a[i];
            else s2+=a[i];
        }
        if(s1<=s2)
        {
            cout<<s1<<"\n"<<n/2<<"\n";
            for(int i=1; i<=n/2; i++)cout<<i*2<<" ";
            cout<<"\n0";
        }
        else
        {
            cout<<s2<<"\n"<<n-n/2<<"\n";
            for(int i=0; i*2+1<=n; i++)cout<<i*2+1<<" ";
            cout<<"\n0";
        }
        return 0;
    }
    return 0;
}