#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, c[maxn];
vector<int> adj[maxn];
long long f[maxn], g[maxn];
int mark_f[maxn], mark_g[maxn], ans[maxn], tot;
void dfs1(int u, int fa) {
  if (adj[u].size() == 1 && fa) {
    f[u] = c[u];
    return;
  }
  long long tmp = -1;
  for (int v : adj[u])
    if (v ^ fa) {
      dfs1(v, u);
      f[u] += f[v];
      tmp = max(tmp, f[v] - g[v]);
    }
  g[u] = f[u] - tmp;
  f[u] = min(f[u], g[u] + c[u]);
}
void dfs2(int u, int fa) {
  if (mark_f[u]) {
    if (f[u] == g[u] + c[u]) ans[++tot] = u, mark_g[u] = 1;
    long long sum = 0;
    for (int v : adj[u])
      if (v ^ fa) sum += f[v];
    if (sum == f[u]) {
      for (int v : adj[u])
        if (v ^ fa) mark_f[v] = 1;
    }
  }
  if (mark_g[u]) {
    long long tmp = -1;
    int cnt = 0;
    for (int v : adj[u])
      if (v ^ fa) tmp = max(tmp, f[v] - g[v]);
    for (int v : adj[u])
      if (v ^ fa && tmp == f[v] - g[v]) cnt++;
    for (int v : adj[u])
      if (v ^ fa) {
        if (cnt > 1 || f[v] - g[v] < tmp) mark_f[v] = 1;
        if (cnt == 1 && tmp == f[v] - g[v]) mark_g[v] = 1;
      }
  }
  for (int v : adj[u])
    if (v ^ fa) dfs2(v, u);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d %d", &u, &v);
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  dfs1(1, 0);
  mark_f[1] = 1;
  dfs2(1, 0);
  sort(ans + 1, ans + 1 + tot);
  printf("%lld %d\n", f[1], tot);
  for (int i = 1; i <= tot; i++) printf("%d%c", ans[i], " \n"[i == tot]);
}
