#include <iostream>
#include <vector>

using namespace std;

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

    int n;
    cin >> n;

    int boja[n+1];
    for(int i = 1; i <= n; i++)
        cin >> boja[i];
    
    vector<vector<int> > listaPovezanosti(n+1);
    for(int i = 1; i < n; i++) {
        int cvor1, cvor2;
        cin >> cvor1 >> cvor2;
        
        listaPovezanosti[cvor1].push_back(cvor2);
        listaPovezanosti[cvor2].push_back(cvor1);
    }
    
    if(listaPovezanosti[1].size() == 1) {
        int cena1 = 0, cena2 = 0;
        for(int i = 1; i <= n; i += 2)
            cena1 += boja[i];
        for(int i = 2; i <= n; i += 2)
            cena2 += boja[i];
        if(cena1 < cena2) {
            cout << cena1 << '\n' << (n+1)/2 << '\n';
            for(int i = 1; i <= n; i += 2)
                cout << i << ' ';
            cout << "0\n";
        }else{
            cout << cena2 << '\n' << n/2 << "\n0\n";
            for(int i = 2; i <= n; i += 2)
                cout << i << ' ';
        }
    }else if(listaPovezanosti[1].size() == n - 1) {
        int cena1 = boja[1], cena2 = 0;
        for(int i = 2; i <= n; i++)
            cena2 += boja[i];
        cout << min(cena1, cena2);
    }else{
        cout << "Otkud znam";
    }

    return 0;
}