#include <bits/stdc++.h>

using namespace std;

#define ll long long
const int INF=1e9;
const ll LINF=1e18;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define pb push_back

void PRINT(int x) {cerr << x;}
void PRINT(ll x) {cerr << x;}
void PRINT(double x) {cerr << x;}
void PRINT(char x) {cerr << '\'' << x << '\'';}
void PRINT(string x) {cerr << '\"' << x << '\"';}
void PRINT(bool x) {cerr << (x ? "true" : "false");}

template<typename T,typename V>
void PRINT(pair<T,V>& x){
    cerr<<"{";
    PRINT(x.fi);
    cerr<<",";
    PRINT(x.se);
    cerr<<"}";
}
template<typename T>
void PRINT(T &x){
    int id=0;
    cerr<<"{";
    for(auto _i:x){
        cerr<<(id++ ? "," : "");
        PRINT(_i);
    }
    cerr<<"}";
}
void _PRINT(){
    cerr<<"]\n";
}
template<typename Head,typename... Tail>
void _PRINT(Head h,Tail... t){
    PRINT(h);
    if(sizeof...(t)) cerr<<", ";
    _PRINT(t...);
}

const int mxN=2e5;

vector<ll> adj[mxN+1];
ll a[mxN+1];
ll dp[mxN+1][2][4];
int min_dub[mxN+1];
int c[mxN+1];
vector<pair<int,pii>> adj1[mxN+1][2][4];
vector<int> ispis[2];

void DfsM(int u,int p){
    min_dub[u]=INF;
    c[u]=c[p]^1;
    for(int v:adj[u]){
        if(v!=p){
            DfsM(v,u);
            min_dub[u]=min(min_dub[u],min_dub[v]+1);
        }
    }
    if(sz(adj[u])==1 && u!=1) min_dub[u]=0;
}

int main(){
    int N; cin>>N;
    vector<int> a(N+1);
    for(int i=1;i<=N;i++) cin>>a[i];
    bool s3=true;
    bool s2=true;
    for(int i=1;i<=N-1;i++){
        int u,v; cin>>u>>v;
        s3&=(abs(u-v)==1);
        s2&=((u==1) || (v==1));
        adj[u].pb(v);
        adj[v].pb(u);
    }
    DfsM(1,0);
    if(s2){
        vector<int> b0,b1;
        ll sum0=0,sum1=0;
        for(int i=1;i<=N;i++){
            if(c[i]){
                sum1+=a[i];
                b1.pb(i);
            }
            else{
                sum0+=a[i];
                b0.pb(i);
            }
        }
        if(sum0<sum1){
            cout<<sum0<<endl;
            cout<<sz(b0)<<endl;
            for(int x:b0) cout<<x<<" ";
            cout<<endl;
            cout<<0<<endl;
        }
        else{
            cout<<sum1<<endl;
            cout<<sz(b1)<<endl;
            for(int x:b1) cout<<x<<" ";
            cout<<endl;
            cout<<0<<endl;
        }
    }
    return 0;
}