#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define fi first
#define sc second
#define endl "\n"

using namespace std;

const int lg = 30;
const int MAXN = 2e5+5;
const long long inf = 1e18;
int vals[MAXN];
vector<vector<int>> graf(MAXN);

signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tt=1;
    //cin >> tt;
    while(tt--)
    {
        int n;
        cin >> n;
        int mx = -inf;
        int index=0;
        int sum = 0;
        for(int i=0; i<n; i++)
        {
            cin >> vals[i+1];
            if(i>0)sum+=vals[i+1];
            if(mx < vals[i+1])
            {
                mx = vals[i+1];
                index = i+1;
            }
        }
        for(int i=0; i<n-1; i++)
        {
            int a,b;cin >> a >> b;
            graf[a].pb(b);
            graf[b].pb(a);
        }
        if(graf[1].size() == n-1)
        {
            if(vals[1] < sum)
            {
                cout << vals[1] << endl;
                cout << 1 << endl;
                cout << 1 << endl;
                cout << 0 << endl;
            }
            else
            {
                cout << sum << endl;
                cout << n-1 << endl;
                for(int i=2; i<=n; i++)cout << i << " ";cout << endl;
                cout << 0 << endl;
            }
        }
        else
        {
            vector<int> dp(n+1, 0);
            dp[1]= vals[1];
            for(int i=2; i<n+1; i++)
            {
                dp[i] = min(dp[i-1], dp[i-2])+ vals[i];
            }
            vector<int> rez;
            vector<int> plavi;
            vector<int> crveni;
            if(dp[n-1] < dp[n])
            {
                int ind = n-1;
                rez.pb(ind);
                while(ind > 2)
                {
                    if(dp[ind - 1] + vals[ind] == dp[ind])ind--;
                    else ind-=2;
                    rez.pb(ind);
                }
                cout << dp[n-1] << endl;
                sort(all(rez));
                int prethodni = 1;
                plavi.pb(rez[0]);
                for(int i=1; i<rez.size(); i++)
                {
                    if(rez[i] != rez[i-1]+1 && prethodni == 1)plavi.pb(rez[i]);
                    else if(rez[i] != rez[i-1]+1 && prethodni == 0)crveni.pb(rez[i]);
                    else if(prethodni == 1)
                    {
                        crveni.pb(rez[i]);
                        prethodni = 0;
                    }
                    else
                    {
                        plavi.pb(rez[i]);
                        prethodni = 1;
                    }
                }
                cout << plavi.size() << endl;
                for(auto x: plavi)cout << x << " ";cout << endl;
                cout << crveni.size() << endl;
                for(auto x: crveni)cout << x << " ";cout << endl;
            }
            else
            {
                int ind = n;
                rez.pb(ind);
                while(ind > 2)
                {
                    if(dp[ind - 1] + vals[ind] == dp[ind])ind--;
                    else ind-=2;
                    rez.pb(ind);
                }
                cout << dp[n] << endl;
                sort(all(rez));
                int prethodni = 1;
                plavi.pb(rez[0]);
                for(int i=1; i<rez.size(); i++)
                {
                    if(rez[i] != rez[i-1]+1 && prethodni == 1)plavi.pb(rez[i]);
                    else if(rez[i] != rez[i-1]+1 && prethodni == 0)crveni.pb(rez[i]);
                    else if(prethodni == 1)
                    {
                        crveni.pb(rez[i]);
                        prethodni = 0;
                    }
                    else
                    {
                        plavi.pb(rez[i]);
                        prethodni = 1;
                    }
                }
                cout << plavi.size() << endl;
                for(auto x: plavi)cout << x << " ";cout << endl;
                cout << crveni.size() << endl;
                for(auto x: crveni)cout << x << " ";cout << endl;
            }
        }

    }
}
/*
5
1 2 1 3 5
1 2
2 3
3 4
4 5
*/
/*
6
1 3 1 1 7 1
1 2
2 3
3 4
4 5
5 6
*/