#include <bits/stdc++.h>
#define f first
#define s second
#define int long long
using namespace std;
const int N = 2e5 + 69;
int n, a[N], dp[N][3], dp2[3], vis[N], dep[N];
vector<int> g[N];
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int tt = 1;
    //cin >> tt;
    while (tt--) {
        cin >> n;
        for (int i = 1;i <= n;i++)
            cin >> a[i];
        for (int i = 1;i <= n - 1;i++) {
            int a, b;
            cin >> a >> b;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        int s = a[1], s2 = 0;
        for (int j = 2;j <= n;j++)
            s2 += a[j];
        cout << min(s,s2) << '\n';
        if (s <= s2) {
            cout << 1 << '\n';
            cout << 1 << '\n';
            cout << 0 << '\n';
        }
        else {
            cout << 0 << '\n';
            cout << n - 1 << '\n';
        for (int j = 2;j <= n;j++)
            cout << j << ' ';
        }


    }
    return 0;
}