#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;

int N, K, u, v, R[100500], B[100500], cntR, cntB;
ll sum, A[100500];
vector<int> VG[100500];

int main()
{
    scanf("%d", &N);
    for(int i = 1; i <= N; i++) scanf("%lld", &A[i]);
    for(int i = 1; i < N; i++)
    {
        scanf("%d %d", &u, &v);
        VG[u].pb(v);
        VG[v].pb(u);
    }
    for(int i = 2; i <= N; i++)
        sum += A[i];
    if(sum < A[1])
    {
        printf("%lld\n", sum);
        printf("%d\n", N - 1);
        for(int i = 2; i <= N; i++)
            printf("%d\n", i);
        printf("\n0\n");
    }
    else
    {
        printf("%lld\n", A[1]);
        printf("1\n1\n");
        printf("0\n");
    }
    return 0;
}