#include <iostream>

using namespace std;

int a[200001];
long long obojeno[200001];
string s1, s2, s3;
int n1, n2, n3;

void oboji(int n)
{
    obojeno[1] = a[1];
    obojeno[2] = a[2];
    s1 = "1";
    s2 = "2";
    n1 = n2 = 1;
    if(obojeno[1] < obojeno[2])
    {
        obojeno[3] = obojeno[1] + a[3];
        s3 = "1 3";
    }
    else
    {
        obojeno[3] = obojeno[2] + a[3];
        s3 = "2 3";
    }
    n3 = 2;
    for(int i = 4; i <= n; i++)
    {
        if(obojeno[i-3] < obojeno[i-2])
        {
            obojeno[i] = obojeno[i-3] + a[i];
            string s = s1 + " " + to_string(i);
            int t = n1 + 1;
            n1 = n2;
            s1 = s2;
            n2 = n3;
            s2 = s3;
            n3 = t;
            s3 = s;
        }
        else
        {
            obojeno[i] = obojeno[i-2] + a[i];
            string s = s2 + " " + to_string(i);
            int t = n2 + 1;
            n1 = n2;
            s1 = s2;
            n2 = n3;
            s2 = s3;
            n3 = t;
            s3 = s;
        }
    }
}

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
    {
        oboji(n);
        if(obojeno[n] > obojeno[n-1])
        {
            cout << obojeno[n-1] << endl << n2 << endl << s2 << endl << 0;
        }
        else
        {
            cout << obojeno[n] << endl << n3 << endl << s3 << endl << 0;
        }
    }
    return 0;
}