#include <bits/stdc++.h>

using namespace std;

long long int inf = 2e18;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> costs(n);
    long long int total = 0;
    for (int i = 0; i < n; i++){
        cin >> costs[i];
        total += costs[i];
    }
    int a, b;
    bool always_one = true;
    for (int i = 1; i < n; i++){
        cin >> a >> b;
        if (a != 1 && b != 1) always_one = false;
    }
    if (always_one){
        if (total - costs[0] > costs[0]){
            cout << costs[0] << endl;
            cout << 1 << endl;
            cout << 1 << endl;
            cout << 0 << endl;
        }
        else{
            cout << total - costs[0] << endl;
            cout << n - 1 << endl;
            for (int i = 2; i <= n; i++) cout << i << " ";
            cout << endl;
            cout << 0 << endl;
        }
    }
    else{
        vector<bool> color(n, false);
        vector<long long int> dp(n);
        vector<int> choice(n);
        for (int i = 0; i < n; i++){
            if (i < 2){
                dp[i] = costs[i];
                choice[i] = -1;
            }
            else{
                dp[i] = inf;
                for (int j = 1; j < 3; j++){
                    if (i - j < 0) break;
                    if (dp[i - j] < dp[i]){
                        dp[i] = dp[i - j];
                        if (j % 2 == 0) color[i] = color[i - j];
                        else color[i] = !color[i - j];
                        choice[i] = i - j;
                    }
                }
                dp[i] += costs[i];
            }
        }
        vector<int> trues, falses;
        int on_pos;
        if (dp[n - 1] < dp[n - 2])
            on_pos = n - 1;
        else
            on_pos = n - 2;
        cout << dp[on_pos] << endl;
        while (on_pos != -1){
            if (color[on_pos]) trues.push_back(on_pos + 1);
            else falses.push_back(on_pos + 1);
            on_pos = choice[on_pos];
        }
        cout << trues.size() << endl;
        for (int elm : trues) cout << elm << " ";
        cout << endl;
        cout << falses.size() << endl;
        for (int elm : falses) cout << elm << " ";
        cout << endl;
    }
    return 0;
}