#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,u,v,p1=1;
    long long s=0;
    cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s+=(long)a[i];
    }
    for(int i=0;i<n-1;i++)
    {
        cin>>u>>v;
        if(u!=1 and v!=1)p1=0;
    }
    if(p1==1)
    {
        if(a[0]<s-a[0])
        {
            cout<<a[0]<<endl;
            cout<<1<<endl;
            cout<<1<<endl;
            cout<<0<<endl;
            
        }
        else
        {
            cout<<s-a[0]<<endl;
            cout<<n-1<<endl;
            for(int i=2;i<=n;i++)
                cout<<i<<" ";
            cout<<endl;
            cout<<0<<endl;
            
        }
    }
}