#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int maxN = 1e5 + 5;
int main(){
    ios;
    int n;
    cin>>n;
    vector<ll> a(n+1);
    for(int i = 1;i<=n;i++)cin>>a[i];
    vector<vector<int>> g(n + 1);
    bool podzadatak1 = true;
    bool podzadatak2 = true;
    for(int i = 0;i < n - 1;i++){
        int u, v;
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
        if(u!=1&&v!=1)podzadatak1 = false;
        if(abs(u-v)>1)podzadatak2 = false;
    }
    if(podzadatak1){
        ll r1 = a[1];
        ll r2 = 0;
        for(int i = 2;i<=n;i++)r2+=a[i];
        if(r1<=r2){
            cout<<r1<<endl;
            cout<<1<<endl;
            cout<<1<<endl;
            cout<<0<<endl;
        }
        else{
            cout<<r2<<endl;
            cout<<n-1<<endl;
            for(int i = 2;i<=n;i++)cout<<i<<" ";
            cout<<endl;
            cout<<0<<endl;
        }
        return 0;
    }
    if(podzadatak2){
        int prvilist = INT_MAX;
        int zadnjilist = INT_MIN;
        for(int i = 1;i<=n;i++){
            if(g[i].size()==1){
                prvilist = min(prvilist, i);
                zadnjilist = max(zadnjilist, i);
            }
        }
        int tr = prvilist;
        vector<int> p[2];
        int parnost = 0;
        vector<ll> sum(2);
        vector<bool> visited(n + 1, false);
        while(tr!=zadnjilist){
            sum[parnost]+=a[tr];
            p[parnost].pb(tr);
            parnost^=1;
            visited[tr]=true;
            for(int adj : g[tr]){
                if(!visited[adj])tr=adj;
            }
        }
        p[parnost].pb(zadnjilist);
        sum[parnost]+=a[zadnjilist];
        if(sum[0]<sum[1]){
            cout<<sum[0]<<endl;
            cout<<p[0].size()<<endl;
            for(int x : p[0])cout<<x<<" ";
            cout<<endl;
            cout<<0<<endl;
        }
        else{
            cout<<sum[1]<<endl;
            cout<<p[1].size()<<endl;
            for(int x : p[1])cout<<x<<" ";
            cout<<endl;
            cout<<0<<endl;
        }


    }


}