#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
int n, arr[N], u, v;
bool vis[N][2];
long long dp[N][2];
vector<int> g[N], ansv;
long long ans = 0;
long long solve(int node, bool b, int prnt) {
  if ((int)g[node].size() == 1 && prnt != -1) return (b ? 0 : arr[node]);
  if (dp[node][b] != -1) return dp[node][b];
  dp[node][b] = (long long)1e18;
  long long sum = 0, mn = (long long)1e18;
  for (int i = 0; i < (int)g[node].size(); i++) {
    if (g[node][i] == prnt) continue;
    sum += solve(g[node][i], 0, node);
    mn = min(mn, solve(g[node][i], 1, node) - solve(g[node][i], 0, node));
  }
  if (b == 1) return dp[node][b] = sum + mn;
  return dp[node][b] = min(sum + mn + arr[node], sum);
}
void build_path(int node, bool b, int prnt) {
  if (vis[node][b]) return;
  if ((int)g[node].size() == 1 && prnt != -1) {
    if (!b) ansv.push_back(node);
    return;
  }
  vis[node][b] = true;
  long long sum = 0, mn = (long long)1e18;
  for (int i = 0; i < (int)g[node].size(); i++) {
    if (g[node][i] == prnt) continue;
    sum += solve(g[node][i], 0, node);
    mn = min(mn, solve(g[node][i], 1, node) - solve(g[node][i], 0, node));
  }
  if (b == 1) {
    int idx = -2;
    for (int i = 0; i < (int)g[node].size(); i++) {
      if (g[node][i] == prnt) continue;
      if (solve(g[node][i], 1, node) - solve(g[node][i], 0, node) == mn) {
        if (idx == -2)
          idx = i;
        else
          idx = -1;
        build_path(g[node][i], 1, node);
      }
    }
    for (int i = 0; i < (int)g[node].size(); i++) {
      if (g[node][i] == prnt || i == idx) continue;
      build_path(g[node][i], 0, node);
    }
    return;
  }
  if (solve(node, b, prnt) == sum) {
    for (int i = 0; i < (int)g[node].size(); i++) {
      if (g[node][i] == prnt) continue;
      build_path(g[node][i], 0, node);
    }
  }
  if (solve(node, b, prnt) == sum + mn + arr[node]) {
    ansv.push_back(node);
    int idx = -2;
    for (int i = 0; i < (int)g[node].size(); i++) {
      if (g[node][i] == prnt) continue;
      if (solve(g[node][i], 1, node) - solve(g[node][i], 0, node) == mn) {
        if (idx == -2)
          idx = i;
        else
          idx = -1;
        build_path(g[node][i], 1, node);
      }
    }
    for (int i = 0; i < (int)g[node].size(); i++) {
      if (g[node][i] == prnt || i == idx) continue;
      build_path(g[node][i], 0, node);
    }
  }
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &arr[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  memset(dp, -1, sizeof(dp));
  printf("%lld ", solve(1, 0, -1));
  build_path(1, 0, -1);
  sort(ansv.begin(), ansv.end());
  ansv.resize(unique(ansv.begin(), ansv.end()) - ansv.begin());
  printf("%d\n", (int)ansv.size());
  for (int i = 0; i < (int)ansv.size(); i++) {
    if (i) putchar(' ');
    printf("%d", ansv[i]);
  }
  puts("");
  return 0;
}
