#include <bits/stdc++.h>
#define MAXN 200010

using namespace std;

typedef  long long ll;

ll n;
ll a[MAXN];
ll b[MAXN]; // boju dobijamo iz dist % 2
ll e[MAXN]; //suma krajnjih na rastojanju i
ll ne[MAXN]; //suma nije-krajnjh na rastojanju i
ll rezuz[MAXN];
ll rezneuz[MAXN];
bool pos[MAXN];
bool ende[MAXN];
vector<ll> sus[MAXN];
vector<ll> prvi;
vector<ll> drugi;
vector<ll> treci;
vector<ll> enadist[MAXN];
vector<ll> nenadist[MAXN];

ll dist = 0;

void dfs(ll v)
{
    b[v] = dist;
    pos[v] = 1;
    dist++;
    bool kraj = true;
    for(auto u : sus[v])
    {
        if(!pos[u])
        {
            kraj = false;
            dfs(u);
        }
    }
    ende[v] = kraj;
    if(ende[v])
    {
        enadist[b[v]].push_back(v);
    }
    else
    {
        nenadist[b[v]].push_back(v);
    }
    dist--;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for(int i = 1; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        sus[x].push_back(y);
        sus[y].push_back(x);
    }
    dfs(1);
    for(int i = 0; i <= n; i++)
    {
        if(ende[i]) e[b[i]] += a[i];
        else ne[b[i]] += a[i];
    }
    rezuz[0] = a[1];
    prvi.push_back(1);
    rezneuz[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        if(rezuz[i - 1] < rezneuz[i - 1] + e[i])
        {
            drugi.clear();
            for(auto x : prvi) treci.push_back(x);
            prvi.clear();
            for(auto x : nenadist[i]) prvi.push_back(x);
        }
        else
        {
            swap(prvi, drugi);
            for(auto x : nenadist[i]) prvi.push_back(x);
            for(auto x : enadist[i]) prvi.push_back(x);
        }
        rezuz[i] = min(rezuz[i - 1] + ne[i], rezneuz[i - 1] + ne[i] + e[i]);
        rezneuz[i] = rezuz[i - 1];
        /**
        cout << i << "\n";
        for(auto x : prvi) cout << x << " ";
        cout << "\n\n";
        **/
    }
    /**
    for(int i = 0; i <= n; i++)
    {
        cout << i << " " << rezuz[i] << " " << rezneuz[i] << "\n";
    }
    **/
    cout << min(rezuz[n], rezneuz[n]) << "\n";
    ll p = 0, c = 0;
    for(auto x : treci) prvi.push_back(x);
    
    prvi.clear();
    for(int i = 1; i <= n; i++) prvi.push_back(i);
    
    for(auto x : prvi)
    {
        if(b[x] % 2 == 0) p++;
        else c++;
    }
    cout << p << "\n";
    for(auto x : prvi)
    {
        if(b[x] % 2 == 0) cout << x << "\n";
    }
    cout << c << "\n";
    for(auto x : prvi)
    {
        if(b[x] % 2 != 0) cout << x << "\n";
    }
    return 0;
}