#include <bits/stdc++.h>

#define int long long int
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

using namespace std;

int res = 0;
vector<int> red;

void dfs(int u,int p,int br,vector<vector<int> >& g,vector<int>& a){
    if(br%2==0){
        res+= a[u-1];
        red.push_back(u);
    }
    for(int i = 0;i<g[u].size();i++){
        if(g[u][i]!=p){
            dfs(g[u][i],u,br+1,g,a);
        }
    }
}

signed main()
{   ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a;
    for(int i = 0;i<n;i++){
        int x;
        cin >> x;
        a.push_back(x);
    }
    vector<vector<int> > g(n+1);
    for(int i = 0;i<n-1;i++){
        int u,v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    bool t3 = true;
    for(int i = 1;i<=n-1;i++){
        for(int j = 0;j<g[i].size();j++){
            if(abs(g[i][j]-i)>1){
                t3 = false;
                break;
            }
        }
    }
    if(t3){
        int sum1 = 0;
        int sum2 = 0;
        for(int i = 0;i<n;i+=2){
            sum1+=a[i];
        }
        for(int i = 1;i<n;i+=2){
            sum2+=a[i];
        }
        if(sum1<sum2){
            cout << sum1 << "\n";
            cout << (n+1)/2 << "\n";
            for(int i = 0;i<n;i+=2){
                cout << i+1 << " ";
            }
            cout << "\n";
            cout << 0 << "\n";
        }else{
            cout << sum2 << "\n";
            cout << n/2 << "\n";
            for(int i = 1;i<n;i+=2){
                cout << i+1 << " ";
            }
            cout << "\n";
            cout << 0 << "\n";
        }
    }
    return 0;
}