//Dedicated to my love, ivaziva
#include "bits/stdc++.h"
#define dbg(x) cerr << #x << ": " << x << endl;
#define ll long long
#define pb push_back
#define all(a) a.begin(),a.end()
#define si(s) (ll)(s.size())
using namespace std;
#define maxn 200005


int n;
int a[maxn];

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

    cin >> n;
    ll x = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        x += a[i];
    }
    int u, v;
    bool drugi_tc = true;
    for(int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        drugi_tc &= (u == 1 || v == 1);
    }
    if(drugi_tc) {
        if(a[1] <= x) {
            cout << a[1] << '\n';
            cout << 1 << '\n';
            cout << 1 << '\n';
            cout << 0 << '\n';
        }
        else {
            cout << x << '\n';
            cout << n - 1 << '\n';
            for(int i = 2; i <= n; i++) cout << i << ' ';
            cout << 0 << '\n';
        }
    }
	return 0;
}