#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 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];
    }

    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 s1 = 0, s2 = 0;
    for (int i = 0; i < n; i+=2) {
        s1 += weights[i];
        if (i + 1 <= n) {
            s2 += weights[i+1];
        }
    }
    if (s1 < s2) {
        std::cout << s1 << std::endl;

        std::cout << (n+1)/2 << std::endl;
        for (int i = 1; i <= n; i+=2) {
            std::cout << i << " ";
        }
        std::cout << std::endl;
        std::cout << 0 << std::endl;
        std::cout << std::endl;
    }
    else {
        std::cout << s2 << std::endl;

        std::cout << n/2 << std::endl;
        for (int i = 2; i <= n; i+=2) {
            std::cout << i << " ";
        }
        std::cout << std::endl;
        std::cout << 0 << std::endl;
        std::cout << 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;
}