#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;
    
    vector<long long> cost (n);
    vector<vector<int>> s (n);
    cin >> cost[0];
    long long sum = 0;
    for(int i=1;i<n;++i){
        cin >> cost[i];
        sum += cost[i];
            
    }

    for(int i=0;i<n-1;++i){
        int temp1,temp2;
        cin >> temp1 >> temp2;

        s[temp1].push_back(temp2);
        s[temp2].push_back(temp1);
    }
    
    if(cost[0] <= sum){
        cout << cost[0] << '\n';
        cout << 1 << '\n';
        cout << 1 << '\n';
        cout << 0 << '\n';
    }
    else{
        cout << sum << '\n';
        cout << n-1 << '\n';
        for(int i=2;i<=n;i++) cout << i << " ";
        cout << '\n';
        cout << 0 << '\n';
    }
    
    
}