#include <bits/stdc++.h>
#define ll long long
#define MAXN 200010
using namespace std;
ll a[MAXN];
vector<ll> G[MAXN];
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n,u,v;
    bool one=true;
    cin >> n;
    for (ll i=1;i<=n;i++)
        cin >> a[i];
    for (ll i=1;i<n;i++)
    {
        cin >> u >> v;
        if (u!=1 && v!=1)
            one=false;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    if (one)
    {
        ll sum=0;
        for (ll i=2;i<=n;i++)
            sum+=a[i];
        cout << min(a[1],sum) << "\n";
        if (sum<a[1])
        {
            cout << n-1 << "\n";
            for (ll i=2;i<=n;i++)
                cout << i << " ";
            cout << "\n0";
        }
        else
            cout << "1\n1\n0";
        return 0;
    }
    return 0;
}