#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 77;
int fa[N], f[N], l[N], r[N], T, sum, w[N], ls[N], siz[N], cnt, n, L, R;
long long ans;
struct E {
  int to, next;
} e[N << 1];
struct node {
  int u, v, w, id;
} E[N];
void add(int u, int v) {
  e[++cnt].to = v;
  e[cnt].next = ls[u];
  ls[u] = cnt;
}
int gf(int x) { return x == fa[x] ? x : fa[x] = gf(fa[x]); }
void dfs(int u, int fa) {
  siz[u] = 1;
  for (int i = ls[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs(v, u);
    l[u] = min(l[u], l[v]);
    r[u] = max(r[u], r[v]);
    siz[u] += siz[v];
  }
  if (siz[u] == 1) l[u] = r[u] = ++T;
  E[u] = (node){l[u], r[u] + 1, w[u], u};
}
bool cmp(node x, node y) { return x.w < y.w; }
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (int i = 1, x, y; i < n; i++) scanf("%d%d", &x, &y), add(x, y), add(y, x);
  memset(l, 0x3f, sizeof(l));
  dfs(1, 0);
  sort(E + 1, E + n + 1, cmp);
  for (int i = 1; i <= T + 1; i++) fa[i] = i;
  int sum = 0;
  for (int L = 1; L <= n; L = R + 1) {
    R = L;
    while (E[R + 1].w == E[L].w && R < n) R++;
    for (int i = L; i <= R; i++) {
      int u = E[i].u, v = E[i].v;
      if (gf(u) != gf(v)) f[E[i].id] = 1, sum++;
    }
    for (int i = L; i <= R; i++) {
      int u = E[i].u, v = E[i].v;
      if (gf(u) != gf(v)) {
        ans += 1ll * E[i].w;
        fa[fa[u]] = fa[v];
      }
    }
  }
  printf("%lld %d\n", ans, sum);
  for (int i = 1; i <= n; i++)
    if (f[i]) printf("%d ", i);
}
