#include <bits/stdc++.h>
using namespace std;
int n, a[200009], hd[200009], cnt, dfn, fa[200009], mb, sq;
struct Edge {
  int to, nxt;
} edge[200009 << 1];
struct LINE {
  int u, v, w, i;
} LN[200009];
bool ok[200009];
long long ans;
int read();
bool cmp(LINE x, LINE y) { return x.w < y.w; }
int ff(int u) { return fa[u] == u ? u : fa[u] = ff(fa[u]); }
void add(int u, int v) {
  edge[++cnt] = (Edge){v, hd[u]};
  hd[u] = cnt;
  edge[++cnt] = (Edge){u, hd[v]};
  hd[v] = cnt;
}
void dfs(int u, int fa) {
  bool ind = false;
  int L = dfn + 1;
  for (int i = hd[u], v; i; i = edge[i].nxt)
    if ((v = edge[i].to) != fa) ind = true, dfs(v, u);
  if (!ind) ++dfn;
  int R = dfn;
  LN[++cnt] = (LINE){L, R + 1, a[u], u};
}
void get_(int L, int R) {
  for (int i = L; i <= R; ++i) {
    int u = ff(LN[i].u), v = ff(LN[i].v);
    if (u != v) ok[LN[i].i] = true;
  }
  for (int i = L; i <= R; ++i) {
    int u = ff(LN[i].u), v = ff(LN[i].v);
    fa[u] = v;
  }
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read();
  for (int i = 1, u, v; i < n; ++i) u = read(), v = read(), add(u, v);
  cnt = 0;
  dfs(1, 1);
  sort(LN + 1, LN + 1 + cnt, cmp);
  for (int i = 1; i <= dfn + 1; ++i) fa[i] = i;
  mb = -10, sq = 0;
  LN[cnt + 1].w = -10;
  for (int i = 1, lst = dfn; i <= cnt; ++i) {
    int u = ff(LN[i].u), v = ff(LN[i].v);
    if (u != v) {
      --lst, ans += (mb = LN[i].w), fa[u] = v;
      ok[LN[i].i] = true;
    }
  }
  for (int i = 1; i <= dfn + 1; ++i) fa[i] = i;
  for (int i = 1; i <= cnt && LN[i].w <= mb; ++i) {
    int j = i;
    while (j < cnt && LN[j + 1].w == LN[i].w) ++j;
    get_(i, j);
    i = j;
  }
  for (int i = 1; i <= n; ++i) sq += ok[i];
  printf("%lld %d\n", ans, sq);
  for (int i = 1; i <= n; ++i)
    if (ok[i]) printf("%d ", i);
  puts("");
  return 0;
}
int read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') f = (c == '-') ? -1 : f, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
