#include <bits/stdc++.h>
#define pc pair<int, string>
#define ll long long

using namespace std;


int main()
{

    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);

    int n;cin>>n;
    ll a[n+5];
    for(int i = 0; i<n; i++)cin>>a[i];

    ll cnt = 0;
    vector< vector <int> > st(n+2);

    for(int i = 0; i<n-1; i++)
    {
        int a, b;cin>>a>>b;
        cnt+=(a==1);
        cnt+=(b==1);
        st[a].push_back(b);
        st[b].push_back(a);
    }

    if(cnt==n-1)
    {
        ll s = 0;
        for(int i = 1; i<n; i++)s+=a[i];
        ll ans = min(a[0], s);
        cout<<ans<<"\n";
        if(ans==a[0])
        {
            cout<<"1\n"<<1<<"\n0\n";
        }else
        {
            cout<<n-1<<"\n";
            for(int i = 2; i<=n; i++)cout<<i<<"\n";
            cout<<"0\n";
        }
        return 0;
    }

    ll s1 = 0, s2 = 0;
    vector<int>koji1, koji2;
    for(int i = 0; i<n; i++)
    {
        if(i%2==0){
            s1+=a[i];
            koji1.push_back(i);
        }
        else{
            s2+=a[i];
            koji2.push_back(i);
        }
    }

    ll ans = min(s1, s2);
    cout<<ans<<"\n";

    if(ans==s1)
    {
        cout<<koji1.size()<<"\n";
        for(int i = 0; i<koji1.size(); i++)
        {
            cout<<koji1[i]<<"\n";
        }
        cout<<"0\n";

    }else
    {
        cout<<koji2.size()<<"\n";
        for(int i = 0; i<koji2.size(); i++)
        {
            cout<<koji2[i]<<"\n";
        }
        cout<<"0\n";
    }


    return 0;
}