#include <bits/stdc++.h>
#define ll long long
using namespace std;
int N;
int u,v;

bool prviZadatak=true;
ll sump=0;

vector<int>kolicina;
vector<vector<int>>graf;
void podesiPocetak(){
    graf.resize(N+7);
    kolicina.resize(N+7);
}
void resiPrvi(){
    for(int i=2;i<=N;i++){
        sump+=kolicina[i];
    }
    if(kolicina[1]<=sump){
        cout<<kolicina[1]<<"\n";
        cout<<1<<"\n";
        cout<<1<<"\n";
    }
    else{
        cout<<sump<<"\n";
        cout<<N-1<<"\n";
        for(int i=2;i<=N;i++){
            cout<<i<<" ";
        }
        cout<<"\n";
    }
    cout<<0<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    podesiPocetak();
    for(int i=1;i<=N;i++){
        cin>>kolicina[i];
    }
    for(int i=0;i<N-1;i++){
        cin>>u>>v;
        graf[u].push_back(v);
        graf[v].push_back(u);
        if(u!=1 && v!=1){
            prviZadatak=false;
        }
    }
    if(prviZadatak){
        resiPrvi();
    }
    return 0;
}