#include <bits/stdc++.h>
#define int long long

using namespace std;
/*
void printajniz(vector<int>a, int n, int x){
    //sort(a.begin(), a.end());
    for (int i=0;i<n;i++){
        for (int j=i;j<n;j++){
            int op1 = (a[i] & a[j]);
            int op2 = (a[i] | a[j]);
            a[i] = op1;
            a[j] = op2;
        }
    }
    for (auto t : a) cout <<t<<' ';
    cout <<'\n';
    cout <<a[x]<<'\n';
}

void solve(){
    int n; cin >> n;
    vector<int>a(n); for (auto &t : a) cin >> t;
    int q; cin >> q;
    while (q--){
        int t,k; cin >> t >> k;
        if (t == 0) printajniz(a,n,(n - k));
        else{
            int x; cin >> x;
            k--;
            for (int i=0;i<n;i++){
                int op1 = (a[i] & a[k]);
                int op2 = (a[i] | a[k]);
                if (op2 == x){
                    a[k] = op2;
                    a[i] = op1;
                    break;
                }
                else if (op1 == x){
                    a[k] = op1;
                    a[i] = op2;
                    break;
                }
            }
        }
    }
}

*/


void solve(){
    int n; cin >> n;
    vector<int>a(n); for (auto &t : a) cin >> t;
    vector<vector<int>>g(n);
    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);
    }
    int sum1 = a[0];
    int sum2 = 0;
    for (int i=1;i<n;i++) sum2 += a[i];
    if (sum1 < sum2){
        cout <<sum1<<'\n';
        cout <<1<<'\n';
        cout <<1<<'\n';
        cout <<0<<'\n';
    }
    else{
        cout <<sum2<<'\n';
        cout <<n-1<<'\n';
        for (int i=2;i<=n;i++) cout <<i<<' ';
        cout <<'\n';
        cout <<0<<'\n';
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int t = 1; //cin >> t;
    while (t--){
        solve();
    }
    return 0;
}