#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,u,v,p1=1,p2=1;
    long long s=0,s1=0,s2=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(abs(u-v)!=1)p2=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;
        }
    }
    else if(p2==1)
    {
    for(int i=0;i<n;i++)
    {
        if(i%2==0)s1+=a[i];
        else s2+=a[i];
    }
    if(s1>s2)
    {
        cout<<s2<<endl;
        cout<<n/2<<endl;
        for(int i=1;i<=n/2;i++)
            cout<<2*i<<" ";
        cout<<endl;
        cout<<0<<endl;
    }
    else
    {
        cout<<s1<<endl;
        cout<<(n+1)/2<<endl;
        for(int i=0;i<(n+1)/2;i++)
            cout<<2*i+1<<" ";
        cout<<endl;
        cout<<0<<endl;
    }
    }
}