#include <iostream>
#include <unordered_map>
#include <map>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <limits>
#include <algorithm>

//#include <bits/stdc++.h>

/*
bool check(std::vector<std::vector<char>>& p, int u, int v) {
    if (seen[u] || seen[v]) return false;
    seen[u] = true;
    seen[v] = true;
    for (auto it = paths[u].begin(); it != paths[u].end(); it++) {
        char c = it->first;
        std::vector<int> pp = it->second;

        for (int p = 0; p < pp.size(); p++) {
            auto finv = paths[pp[p]][c];
            if (finv.size() > 0) {

                for (int i = 0; i < finv.size(); i++) {

                }
            }
        }
    }
}*/

int min1(int a, int b) {
return (a < b) ? a : b;
}

std::vector<int> dp;
std::vector<int> dpfr;

int rec(int i, std::vector<int>& w) {
    //std::cout << i << std::endl;;
    if (i == w.size()-1 || i == w.size()-2) {
        dp[i] = w[i];
        dpfr[i] = i;
        return dp[i];
    }
    else if (i >= w.size()) return 0;

    if (dp[i] > 0) {
        return dp[i];
    }

    int k1 = rec(i+1, w);
    int k2 = rec(i+2, w);
    int k3 = rec(i+3, w);

    int k = min1(k1, min1(k2, k3));

    if (k == k1) {
    dpfr[i] = i+1;
    }
    else if (k == k2) {
    dpfr[i] = i+2;
    }
    if (k == k3) {
    dpfr[i] = i+3;
    }

    k += w[i];

    dp[i] = k;
    return k;
}

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

    int n;
    std::cin >> n;

    std::vector<int> weights(n);
    for (int i = 0; i < n; i++) {
        std::cin >> weights[i];
    }

    dp = std::vector<int>(n+4, 0);
    dpfr = std::vector<int>(n+4, 0);

    std::unordered_map<int, std::vector<int>> con;

    std::vector<int> fin;

    for (int i = 0; i < n-1; i++) {
        int a, b;
        std::cin >> a >> b;
        /*con[a].push_back(b);
        con[b].push_back(a);
        if (con[a].size() > 2) {
            fin.push_back(a);
        }
        else if (con[b].size() > 2) {
            fin.push_back(b);
        }*/
    }
    int o1 = rec(0, weights);
    //std::cout << "Result: " << o1 << std::endl;
    std::vector<int> path;
    for (int i = 0; i < n+1; i++) {
        std::cout << dpfr[i] << " ";
    }
    std::cout << std::endl;
    int i = 0;
    path.push_back(i);
    while (i < dpfr.size() && dpfr[i] != i) {
            //system("pause");
            //std::cout << i << " "<< dpfr[i] << std::endl;
        i = dpfr[i];
        path.push_back(i);
    }
    dpfr = std::vector<int>(n+1, 0);
    dp = std::vector<int>(n+1, 0);
    int o2 = rec(1, weights);
    /*std::cout << "a" << std::endl;
    std::cout << "Result: " << o2 << std::endl;*/
    for (int j = 0; j < n+1; j++) {
        std::cout << dpfr[j] << " ";
    }
    std::cout << std::endl;
    if (o2 < o1) {
        path.clear();
            i = 1;
            path.push_back(i);
        while (dpfr[i] != i) {
            i = dpfr[i];
            path.push_back(i);
        }
    }

    std::cout << min1(o1, o2) << std::endl;
    std::cout << path.size() << std::endl;
    for (int i = 0; i < path.size(); i++) {
        std::cout << path[i] << " ";
    }
    std::cout << std::endl;
    std::cout << 0 << std::endl;
    /*int s = 0;
    int sred = 0;
    int nred = 0;
    int sblue = 0;
    int nblue = 0;
    for (int i = 0; i < fin.size(); i++) {
        s += weights[fin[i]];
    }*/
    /*std::cout << s << std::endl;
    std::cout << fin.size() << std::endl;
    std::cout << 1 << std::endl;
    std::cout << 0 << std::endl;*/

    return 0;
}