#include <bits/stdc++.h>

using namespace std;

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

    long long n,i;
    cin >> n;

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

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

    }

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

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


    vector<long long> dp (n+1);
    set<int> clanc;
    set<int> clanp;

    dp[0] = cost[0];
    dp[1] = cost[1];


    for(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]);


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

    clanc.insert(i+1);
    int brojCrv = 1;
    int brojPlv = 0;
    bool vena = true;

    while(i > 1){

        if(dp[i]-dp[i-1] == cost[i]){

            i--;
            vena = !vena;
            if(vena){
                brojCrv++;
                clanc.insert(i+1);
            }
            else
            {
                brojPlv++;
                clanp.insert(i+1);
            }
        }
        else{

            i-=2;
            if(vena){
                brojCrv++;
                clanc.insert(i+1);
            }
            else{
                brojPlv++;
                clanp.insert(i+1);
            }
        }
    }

    cout << dp[n] << '\n';
    cout << brojCrv << '\n';
    for(int x : clanc) cout << x << " ";
    cout << '\n';
    cout << brojPlv << '\n';
    for(int x : clanp) cout << x << " ";
    cout << '\n';

}