#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
//nadam se da niko ne cita :))

ll n, a[200020], dp[2][200020];
vector<ll>tree[200020];
bool check[200020];
int last=-1;

int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<n; i++)
    {
        int u, v; cin>>u>>v;
        tree[u].push_back(v);
        tree[v].push_back(u);
    }
    ll sum=0;
    for(int i=2; i<=n; i++)sum+=a[i];
    if(sum>=a[1])
    {
        cout<<a[1]<<"\n"<<1<<"\n"<<1<<"\n"<<0;
        return 0;
    }
    cout<<sum<<"\n"<<n-1<<"\n";
    for(int i=2; i<=n; i++)cout<<i<<" ";
    cout<<"\n0";
    return 0;
}