#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 400010;
const int INF = 2147483600;
const long long Mod = 998244353LL;
int N;
int C[MAXN + 1];
int Node[MAXN << 1], Next[MAXN << 1], Root[MAXN + 1], cnt, deg[MAXN + 1];
inline void insert(int u, int v) {
  Node[++cnt] = v;
  Next[cnt] = Root[u];
  Root[u] = cnt;
  ++deg[u];
}
struct data {
  int u, v, id, w;
} ed[MAXN + 1];
int nod;
int L[MAXN + 1], R[MAXN + 1];
bool cmp(data a, data b) { return a.w < b.w; }
bool flag[MAXN + 1];
int all;
int fa[MAXN + 1];
bool cmpw(data a, data b) { return a.w < b.w; }
inline int find(int x) { return (x == fa[x] ? x : (fa[x] = find(fa[x]))); }
inline void dfs(int k, int Fa) {
  L[k] = nod;
  if (deg[k] == 1 && k != 1) ++nod;
  for (int x = Root[k]; x; x = Next[x]) {
    int v = Node[x];
    if (v == Fa) continue;
    dfs(v, k);
  }
  R[k] = nod;
  ed[++all].u = L[k];
  ed[all].v = R[k];
  ed[all].id = k;
  ed[all].w = C[k];
}
int main() {
  N = read();
  for (int i = 1; i <= N; i++) C[i] = read();
  for (int i = 1; i < N; i++) {
    int u = read(), v = read();
    insert(u, v);
    insert(v, u);
  }
  dfs(1, 0);
  long long ans = 0;
  int sum = 0;
  sort(ed + 1, ed + all + 1, cmpw);
  for (int i = 0; i <= N; i++) fa[i] = i;
  for (int i = 1, r; i <= all; i = r + 1) {
    r = i;
    while (r <= all && ed[r].w == ed[i].w) ++r;
    --r;
    for (int j = i; j <= r; j++) {
      if (find(ed[j].u) != find(ed[j].v)) flag[ed[j].id] = 1, ++sum;
    }
    for (int j = i; j <= r; j++) {
      if (find(ed[j].u) != find(ed[j].v)) {
        ans += ed[j].w;
        fa[find(ed[j].v)] = find(ed[j].u);
      }
    }
  }
  printf("%lld %d\n", ans, sum);
  for (int i = 1; i <= N; i++)
    if (flag[i]) printf("%d ", i);
  return 0;
}
