#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    unsigned long long zbir = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        zbir += a[i];
    }
    zbir -= a[0];
    vector<vector<int> > graf(n);
    int v, u;
    for (int i = 0; i < n - 1; i++) {
        cin >> v >> u;
        v--;
        u--;
        graf[v].push_back(u);
        graf[u].push_back(v);
    }
    if (a[0] <= zbir)
        cout << a[0] << '\n' << 1 << '\n' << 1 << '\n' << 0 << '\n';
    else {
        cout << zbir << '\n' << n - 1 << '\n';
        for (int i = 2; i <= n; i++)
            cout << i << ' ';
        cout << '\n';
        cout << 0 << '\n';
    }
    return 0;
}