#include <bits/stdc++.h>

using namespace std;

#define MAXN 200010

long long n;
long long a[MAXN];
vector<long long> adj[MAXN];
long long pos[MAXN];

void dfs(long long node,long long boja)
{
    pos[node]=boja;
    long long s=adj[node].size();
    for (long long i=0;i<s;i++)
    {
        long long sled=adj[node][i];
        long long sledboja;
        if (boja==1) sledboja=0;
        else sledboja=1;
        if (pos[sled]==-1) dfs(sled,sledboja);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n;
    for (long long i=1;i<=n;i++) cin>>a[i];
    for (long long i=1;i<n;i++)
    {
        long long x,y;cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    if (adj[1].size()==n-1)
    {
        ///proradilo
        long long ans1=a[1],ans2=0;
        for (long long i=2;i<=n;i++) ans2+=a[i];
        long long ans=min(ans1,ans2);
        cout<<ans<<endl;
        if (ans==ans1)
        {
            cout<<1<<endl;cout<<1<<endl;
            cout<<0<<endl;
        }
        else if (ans==ans2)
        {
            cout<<n-1<<endl;
            for (long i=2;i<=n;i++) cout<<i<<" ";
            cout<<endl;cout<<0<<endl;
        }
        return 0;
    }
    for (long long i=1;i<=n;i++) pos[i]=-1;
    dfs(1,0);
    long long ans0=0,ans1=0;
    long long br0=0,br1=0;
    for (long long i=1;i<=n;i++)
    {
        if (pos[i]==0) {ans0+=a[i];br0++;}
        if (pos[i]==1) {ans1+=a[i];br1++;}
    }
    if (ans0<ans1)
    {
        cout<<ans0<<endl;
        cout<<br0<<endl;
        for (long long i=1;i<=n;i++)
        {
            if (pos[i]==0) cout<<i<<" ";
            else continue;
        }
        cout<<0<<endl;
    }
    else
    {
        cout<<ans1<<endl;
        cout<<br1<<endl;
        for (long long i=1;i<=n;i++)
        {
            if (pos[i]==1) cout<<i<<" ";
            else continue;
        }
        cout<<0<<endl;
    }
    return 0;
}