#include <bits/stdc++.h>

using namespace std;

vector<int> adj[200001];
long long a[200001];
bool obojen[200001] = {0};
long long suma = 0;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n;
    cin >> n;
    bool z = true;
    cin >> a[1];
    for (int i = 2; i <= n; i++) {
        cin >> a[i];
        if(a[i] != a[i - 1]) z = false;
    }
    int u, v;
    for(int i = 0; i < n - 1; i++) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
  //  if(z){
  //  return 0;
  //  }
     if(adj[n][0] == 1){
        for(int i = 0; i < n - 1; i++) {
        suma += a[i + 2];
        }
        if(suma >= a[1]) {
            cout << a[1] << "\n" << 1 << "\n" << 1 << "\n" << 0;
        }
        else{
            cout << suma << "\n" << n - 1 << "\n";
            for(int i = 2; i <=n; i++) cout << i << " ";
            cout << "\n" << 0;
        }
    }
    else {
        int c = 0, p = 0;
        for(int i = 1; i <=n; i+=2) {
            if(n - i == 2) {
                if(a[i] + a[i + 2] >= a[i + 1]){
                    suma+=a[i + 1];
                    p++;
                    obojen[i + 1] = true;
                }
                else {
                    suma+=a[i];
                    suma+=a[i+2];
                    c++;
                    obojen[i] = true;
                    obojen[i+2] = true;
                }
                break;
            }
            else {
                if(a[i] < a[i + 1]) {
                    suma+=a[i];
                    c++;
                    obojen[i] = true;
                }
                else {
                    suma+=a[i + 1];
                    p++;
                    obojen[i + 1] = true;
                }

            }
        }
        bool u = false;
        cout << suma << "\n" << c << "\n";
        for(int i = 1; i <= n; i+=2) {
            if(obojen[i]) {cout << i << " "; u = true;}
        }
        if(u) cout << "\n";
        cout << p << "\n";
        for(int i = 2; i <= n; i+=2) {
            if(obojen[i]) cout << i << " ";
        }
    }
    return 0;
}