#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 tc2[N];

signed main()
{
    int n;
    cin>>n;
    int a[n];
    int l=1e9;
    int l1=1e9;
    int r=0;
    bool tc1=true;
    bool tc2=true;
    for(int i=1; i <= n; i++)cin >>a[i];
    for(int i=0; i <n-1; i++){
        int x,y;
        cin >> x >> y;
        x--;
        y--;
        if(x!=1)l1=min(l1,x);
        if(y!=1)l1=min(l1,y);
        l=min(l,x);
        l=min(l,y);
        r=max(r,x);
        r=max(r,y);

        if(abs(x-y)!=1)tc2=false;
        if(x!=1 && y!=1)tc1=false;
        vek[x].push_back(y);
        vek[y].push_back(x);
    }
    if(tc2){
        int br1=0;
        int sum1=0;
        int sum2=0;
        int br2=0;
        for(int i=l+1; i <= r+1;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=l+1; i <= r+1; i++){
                if(i%2==0)cout<<i<<" ";
            }
            cout<<"\n";
            cout<<0<<"\n";
        }else{
             cout<<sum2<<"\n";
            cout<<br2<<"\n";
            for(int i=l+1; i <= r+1; i++){
                if(i%2!=0)cout<<i<<" ";
            }
            cout<<"\n";
            cout<<0<<"\n";

        }
    }
    else if(tc1){
        int sum1=a[1];
        l1++;
        r++;
        int sum2;
        int br2=0;
        for(int i=l1; i <= r; i++){
            sum2+=a[i];
            br2++;
        }
        if(sum1<sum2){
            cout<<sum1<<"\n";
            cout<<1<<"\n";
            cout<<a[0];
            cout<<"\n";
            cout<<0<<"\n";
        }else{
             cout<<sum2<<"\n";
            cout<<br2<<"\n";
            for(int i=l1; i <= r; i++){
                cout<<i<<" ";
            }
            cout<<"\n";
            cout<<0<<"\n";

        }
    }return 0;



}