#include <bits/stdc++.h>

using namespace std;

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

    int n;
    cin >> n;

    vector<long long> cost (n);
    vector<vector<int>> s (n);

    cin >> cost[0];
    long long sum = 0;
    for(int i=1;i<n;++i){
        cin >> cost[i];
        sum += cost[i];

    }

    for(int i=0;i<n-1;++i){
        int temp1,temp2;
        cin >> temp1 >> temp2;

        //s[temp1].push_back(temp2);
        //s[temp2].push_back(temp1);
    }


    long long sum1 = 0;
    vector<long long> dp (n+1);
    unordered_set<int> clan;
    dp[0] = cost[0];
    dp[1] = cost[1];


    for(int i=2;i<n;i++){
       dp[i] = min(dp[i-1],dp[i-2]) + cost[i];
    }
    dp[n] = min(dp[n-1],dp[n-2]);



    int i;
    if(dp[n-1] < dp[n-2]) i = n-1;
    else i = n-2;

    clan.insert(i+1);
    int broj = 1;

    while(i > 1){

        if(dp[i]-dp[i-1] == cost[i]) i--;
        else i-=2;

        broj ++;
        clan.insert(i+1);
    }

    cout << dp[n] << '\n';
    cout << broj << '\n';
    for(auto x : clan) cout << x << " ";
    cout << '\n';
    cout << 0;
}