#include <iostream>

using namespace std;

int a[200001];
/*long long obojeno[200001];

long long oboji(int n)
{
    obojeno[1] = a[1];
    obojeno[2] = a[2];
    obojeno[3] = a[3] + min(obojeno[1], obojeno[2]);
    for(int i = 4; i <= n; i++)
        obojeno[i] = a[i] + min(obojeno)
}*/

int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    int sl = 0;
    for(int i = 0; i < n-1; i++)
    {
        int x, y;
        cin >> x >> y;
        if(x > y)
            swap(x, y);
        if(x == 1 && y > 2)
            sl = 1;
    }
    if(sl == 1)
    {
        long long s = 0;
        for(int i = 2; i <= n; i++)
            s += a[i];
        if(s >= a[1])
            cout << a[1] << endl << 1 << endl << 1 << endl << 0;
        else
        {
            cout << s << endl << n-1 << endl;
            for(int i = 2; i <= n; i++)
                cout << i << " ";
            cout << endl << 0;
        }
    }
    /*else
    {

    }*/
    return 0;
}