#include <bits/stdc++.h>

using namespace std;


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 cout << 0 << endl;
    return 0;
}