#include <bits/stdc++.h>
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl '\n'
#define pb push_back
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const int maxN = 1e5 + 5;
int main(){
    ios;
    int n;
    cin>>n;
    vector<ll> a(n+1);
    for(int i = 1;i<=n;i++)cin>>a[i];
    vector<vector<int>> g(n + 1);
    bool podzadatak1 = true;
    bool podzadatak2 = true;
    for(int i = 0;i < n - 1;i++){
        int u, v;
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
        if(u!=1&&v!=1)podzadatak1 = false;
        if(abs(u-v)>1)podzadatak2 = false;
    }
    if(podzadatak1){
        ll r1 = a[1];
        ll r2 = 0;
        for(int i = 2;i<=n;i++)r2+=a[i];
        if(r1<=r2){
            cout<<r1<<endl;
            cout<<1<<endl;
            cout<<1<<endl;
            cout<<0<<endl;
        }
        else{
            cout<<r2<<endl;
            cout<<n-1<<endl;
            for(int i = 2;i<=n;i++)cout<<i<<" ";
            cout<<endl;
            cout<<0<<endl;
        }
        return 0;
    }
    if(podzadatak2){
        ll nepar = 0;
        ll par = 0;
        ll pbroj = 0;
        ll nbroj = 0;
        for(int i = 1;i<=n;i++){
            if(i%2==0){
                par+=a[i];
                pbroj++;
            }
            else{
                nepar+=a[i];
                nbroj++;
            }
        }
        if(par<nepar){
            cout<<par<<endl;
            cout<<pbroj<<endl;
            for(int i = 2;i<=n;i+=2)cout<<i<<" ";
            cout<<endl;
            cout<<0<<endl;
        }
        else{
            cout<<nepar<<endl;
            cout<<nbroj<<endl;
            for(int i = 1;i<=n;i+=2)cout<<i<<" ";
            cout<<endl;
            cout<<0<<endl;
        }

    }


}