#include<bits/stdc++.h>

using namespace std;

#define MAXV 200005

int n;
vector<int> boje(1), g[MAXV];

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

    int i, j, sum_bez_1 = 0;
    cin >> n;
    for(i=1;i<=n;i++){
        int x;
        cin >> x;
        boje.push_back(x);
        if(i != 1){
            sum_bez_1 += x;
        }
    }

    for(i=1;i<n;i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    // Ispis
    if(g[1].size() == n-1){
        if(sum_bez_1 > boje[1]){
            cout << boje[1] << "\n";
            cout << 1 <<"\n";
            cout << 1 <<"\n";
            cout << 0;
        }
        else{
            cout << sum_bez_1 << "\n";
            cout << n-1 <<"\n";
            for(i=2;i<=n;i++){
                cout << i << " ";
            }
            cout << "\n";
            cout << 0;

        }

    }
    return 0;
}