#include <bits/stdc++.h>
using namespace std;
const int Maxn = 200005;
long long dp[Maxn][2], c[Maxn];
bool Every[Maxn];
int pre[Maxn];
int n;
vector<int> G[Maxn];
vector<int> ans;
void dfs(int x, int p) {
  bool flag = true;
  long long tot = 0;
  long long Mx1 = -1, Mx2 = -1;
  int id1, id2;
  for (int i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (v == p) continue;
    flag = false;
    dfs(v, x);
    tot += dp[v][0];
    long long tmp = dp[v][0] - dp[v][1];
    if (tmp > Mx1) {
      id2 = id1;
      Mx2 = Mx1;
      Mx1 = tmp;
      id1 = v;
    } else if (tmp > Mx2) {
      id2 = v;
      Mx2 = tmp;
    }
  }
  if (flag) {
    dp[x][0] = c[x];
    return;
  }
  if (Mx1 == Mx2) {
    Every[x] = true;
  } else {
    pre[x] = id1;
  }
  dp[x][0] = tot;
  dp[x][1] = tot - Mx1;
  if (dp[x][1] + c[x] < dp[x][0]) {
    dp[x][0] = dp[x][1] + c[x];
  }
}
bool gd[Maxn];
void dfs2(int x, int p, int tp) {
  if (c[x] == 0) {
    gd[x] = 1;
  }
  if (tp == 0 && dp[x][1] + c[x] == dp[x][0]) {
    gd[x] = 1;
  }
  long long tmp = 0;
  for (int i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (v == p) continue;
    tmp += dp[v][0];
  }
  if (tp == 0 && tmp == dp[x][0]) {
    for (int i = 0; i < G[x].size(); i++) {
      int v = G[x][i];
      if (v == p) continue;
      dfs2(v, x, 0);
    }
    return;
  }
  if (Every[x]) {
    for (int i = 0; i < G[x].size(); i++) {
      int v = G[x][i];
      if (v == p) continue;
      dfs2(v, x, 0);
    }
    return;
  }
  for (int i = 0; i < G[x].size(); i++) {
    int v = G[x][i];
    if (v == p) continue;
    if (v != pre[x])
      dfs2(v, x, 0);
    else
      dfs2(v, x, 1);
  }
  return;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &c[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs(1, -1);
  dfs2(1, -1, 0);
  for (int i = 1; i <= n; i++)
    if (gd[i]) ans.push_back(i);
  printf("%I64d %d\n", dp[1][0], ans.size());
  for (int i = 0; i < ans.size(); i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
