#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

const int MAX=1e6+3;
int n, q;
ll c[MAX];
bool v[MAX];
vector<int> g[MAX];
vector<int> topo;
ll deg[MAX];
ll d0[MAX], d1[MAX];
bool drugi=true, treci=true, peti=true;

void dfs(int node){
    v[node]=1;
    for(auto x : g[node]){
        if(!v[x]) dfs(x);
    }
    topo.push_back(node);
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i=0;i<n;++i) cin >> c[i];
    for(int i=0;i<n-1;++i){
        int a, b; cin >> a >> b; a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
        //if(a!=1 && b!=1) drugi=false;
        deg[a]++; deg[b]++;
    }
    if(deg[0]==n-1){
        ll suma=0;
        for(int i=1;i<n;++i) suma+=c[i];
        if(suma<c[0]){
            cout << suma << '\n';
            cout << n-1 << '\n';
            for(int i=2;i<=n;++i) cout << i << ' ';
            cout << '\n' << 0 << '\n';
        }
        else{
            cout << c[0] << '\n';
            cout << 1 << '\n';
            cout << 1 << '\n';
            cout << 0 << '\n';
        }
    }
    else assert(0);


    return 0;
}
/**
21
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 2
2 3
2 4
1 5
5 6
6 7
6 8
8 9
6 10
10 11
10 12
12 13
12 14
14 15
15 16
15 17
14 18
14 19
19 20
20 21
*/