#include <bits/stdc++.h>

using namespace std;

const int MAXN = 200005;
vector<int> g[MAXN];

long long dp[MAXN][3];
long long A[MAXN];
bool special[MAXN];

vector<int> bojeni[MAXN][3];
int bojenje[MAXN];
void dfs(int x, int from) {
    for (auto a: g[x]) {
        if (a != from) {
            dfs(a, x);
        }
    }

    // dp[x][0]
    for (auto a: g[x]) {
        if (a != from) {
            dp[x][0] += dp[a][1];
            bojeni[x][0].push_back(a);
        }
    }

    // dp[x][1]
    dp[x][1] += A[x];
    for (auto a: g[x]) {
        if (a != from) {
            long long v1, v2;
            v1 = dp[a][0];
            v2 = dp[a][1];
            dp[x][1] += min(v1, v2);
            if (v2 < v1) {
                bojeni[x][1].push_back(a);
            }
        }
    }

    //cout << x << " " << dp[x][0] << " " << dp[x][1] << endl;
}

void dfs2(int x, int s, int prev) {
    //cout << x << " " << s << endl;
    for (auto a: bojeni[x][s]) {
        if (s == 1 && bojenje[x] == -1) assert(false);
        if (s == 0 && bojenje[x] != -1) assert(false);
        if (bojenje[x] == -1) bojenje[a] = 0;
        else bojenje[a] = (1 - bojenje[x]);
        //cout << "bojim: " << a << " " << bojenje[a] << endl;
    }

    for (auto a: g[x]) {
        if (a != prev) {
            if (bojenje[a] == -1) {
                dfs2(a, 0, x);
            }
            else {
                dfs2(a, 1, x);
            }
        }
    }

}

int main()
{
#ifdef DRZAVNO
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif // DRZAVNO
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> A[i];
        bojenje[i] = -1;
    }

    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(1, -1);
    long long ans1 = dp[1][0];
    long long ans2 = dp[1][1];
    if (ans1 < ans2) {
        bojenje[1] = -1;
        dfs2(1, 0, -1);
    }
    else {
        bojenje[1] = 0;
        dfs2(1, 1, -1);
    }
    int last = -1;
    for (int i = 1; i <= n; i++) {
        if (bojenje[i] != -1) {
            if (last == i - 1) {
                if (A[i] > A[last]) {
                    bojenje[i] = -1;
                }
                else {
                    bojenje[last] = -1;
                    last = i;
                }
            }
            else {
                last = i;
            }
        }
      // cout << dp[i][0] << ' ' << dp[i][1] << endl;
    }

    long long ans = 0;
    vector<int> r;
    vector<int> b;
    for (int i = 1; i <= n; i++) {
        if (bojenje[i] == 0) {
            r.push_back(i);
            ans += A[i];
        }
        if (bojenje[i] == 1) {
            b.push_back(i);
            ans += A[i];
        }
    }

    cout << ans << '\n';

    int s1 = r.size();
    int s2 = b.size();
    cout << s1 << '\n';
    for (int i = 0; i < s1; i++) {
        cout << r[i] << ' ';
    }
    cout << '\n';
    cout << s2 << '\n';
    for (int i = 0; i < s2; i++) {
        cout << b[i] << ' ';
    }
    cout << '\n';



    return 0;
}