#include <bits/stdc++.h>
#define int long long

#define first f
#define second s

using namespace std;
const int N=2e5+10;

vector<int> vek[N];
bool tc1[N];

signed main()
{
   int n;
   cin >> n;
   int a[n];
   for(int i=0; i < n; i++)cin >> a[i];
   bool tc11 = true;
   int pl=1e9;
   int pr=0;
   for(int i=0; i < n-1; i++){
        int x,y;
        cin >> x >> y;
        x--; y--;
        pl=min(pl,x);
        pl=min(pl,y);
        pr=max(pr,x);
        pr=max(pr,y);
        tc1[x]=true;
        tc1[y]=true;
        if(x!=0 && y!=0)tc11=false;

   }
    if(tc11){
        int sum1=a[0];
        int sum2=0;
        int br=0;
        for(int i=1; i< n; i++){
            if(tc1[i]){
                    sum2+=a[i];
                br++;
            }

        }
        if(sum1<sum2){
            cout<<sum1<<"\n";
            cout<<1<<"\n";
            cout<<1<<"\n";
            cout<<"0\n";
        }else{
            cout<<sum2<<"\n";
            cout<<br<<"\n";
             for(int i=1; i< n; i++){
                if(tc1[i]){
                      cout<<i+1<<" ";
                }
            }
            cout<<"\n";
            cout<<"0";
        }
    }else{
        //cout<<pl<<" "<<pr<<"\n";
        int sum1=0;
        int br1=0;
        int br2=0;
        int sum2=0;
        for(int i=pl; i <= pr; i++){
            if(i%2==0){
                sum1+=a[i];
                br1++;
            }
            else{
                sum2+=a[i];
                br2++;
            }
        }
        if(sum1<sum2){
            cout<<sum1<<"\n";
            cout<<br1<<"\n";
             for(int i=pl; i <= pr; i++){
                if(i%2==0){
                    cout<<i+1<<" ";
                }
            }
            cout<<"\n";
            cout<<"0";
        }else{
            cout<<sum2<<"\n";
            cout<<br2<<"\n";
             for(int i=pl; i<= pr; i++){
                 if(i%2!=0){
                    cout<<i+1<<" ";
                }
            }
            cout<<"\n";
            cout<<"0";
        }


    }

}