#include<bits/stdc++.h>
using namespace std;
int main(){

    int n;
    cin>>n;

    int niz[n+5];
    vector<vector<int> > v( n );

    int pom;
    bool bulg = true;

    for(int i=0;i<n;i++){
        cin>>niz[i];
        if(i == 0){

            pom = niz[i];
            continue;
        }
        if(niz[i] != pom){
            bulg = false;
        }
    }

    int a,b;
    int dete[n+5];
    for(int i=0;i<n;i++){
        dete[i] = 0;
    }

    for(int i=0;i<n-1;i++){

        cin>>a>>b;

        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);

        dete[a]++;
        dete[b]++;
    }

    if(v[0].size() == n-1){

        int u=0;
        for(int i=1;i<n;i++){

            u += niz[i];
        }

        if(niz[0] <= u){

            cout<<niz[0]<<endl;
            cout<<1<<endl;
            cout<<1<<endl;
            cout<<0<<endl;
        }
        else{

            cout<<u<<endl;
            cout<<n-1<<endl;
            for(int i=1;i<n;i++){

                cout<<i+1<<" ";
            }
            cout<<endl;
            cout<<0;
        }
    }
    else if(bulg){

        bool da[n+5];
        for(int i=0;i<n;i++){
            da[i] = false;
        }

        vector<pair<int,int> > vp;

        for(int i=0;i<n;i++){

            vp.emplace_back(dete[i] , i);
        }
        sort(vp.begin(),vp.end());
        pair<int,int> par;
        int k;
        int brojac = 1;
        int i=0;
        int rez = 0;

        while(brojac < n){

            par = vp[i];
            k = par.second;
            rez++;
            int d;

            for(int u=0;u<v[k].size();u++){

                d = v[k][u];
                if(!da[d]){
                    brojac++;
                    da[d] = true;
                }
            }

            i++;
            while(vp[i].first = vp[i+1].first && da[vp[i].second]){
                i++;
            }
        }
        cout<<rez * niz[0];

    }

}