#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5, inf = 0x3f3f3f3f;
int n, w[N], f[N], T, l[N], r[N], p, sum, siz[N];
long long ans;
vector<int> e[N];
struct node {
  int u, v, o, w;
} s[N];
bool ok[N];
int read() {
  int x = 0, f = 1;
  char s;
  while ((s = getchar()) > '9' || s < '0')
    if (s == '-') f = -1;
  while (s >= '0' && s <= '9')
    x = (x << 1) + (x << 3) + (s ^ 48), s = getchar();
  return x * f;
}
bool cmp(node a, node b) { return a.w < b.w; }
void init() {
  for (int i = 1; i <= T + 1; ++i) f[i] = i;
}
int Find(int x) { return x == f[x] ? x : f[x] = Find(f[x]); }
void dfs(int u, int fa) {
  siz[u] = 1;
  l[u] = inf;
  for (int i = 0; i < e[u].size(); ++i) {
    int v = e[u][i];
    if (v == fa) continue;
    dfs(v, u);
    siz[u] += siz[v];
    l[u] = min(l[u], l[v]);
    r[u] = max(r[u], r[v]);
  }
  if (siz[u] == 1) l[u] = r[u] = ++T;
  s[++p] = (node){l[u], r[u] + 1, u, w[u]};
}
int main() {
  n = read();
  for (int i = 1; i <= n; ++i) w[i] = read();
  int u, v;
  for (int i = 1; i < n; ++i) {
    u = read(), v = read();
    e[u].push_back(v), e[v].push_back(u);
  }
  dfs(1, 0);
  init();
  sort(s + 1, s + p + 1, cmp);
  int R, x, y;
  for (int L = 1; L <= p; L = R + 1) {
    R = L;
    while (s[R + 1].w == s[L].w && R < p) ++R;
    for (int i = L; i <= R; ++i) {
      x = s[i].u, y = s[i].v;
      if (Find(x) ^ Find(y)) ++sum, ok[s[i].o] = 1;
    }
    for (int i = L; i <= R; ++i) {
      x = s[i].u, y = s[i].v;
      if (Find(x) ^ Find(y)) {
        ans += s[i].w;
        f[Find(x)] = Find(y);
      }
    }
  }
  printf("%lld %d\n", ans, sum);
  for (int i = 1; i <= n; ++i)
    if (ok[i]) printf("%d ", i);
  puts("");
  return 0;
}
