#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
int n;
long long ans;
int a[MAXN];
bool vis[MAXN];
int Read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x * 10) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
void Put1(long long x) {
  if (x > 9) Put1(x / 10);
  putchar(x % 10 ^ 48);
}
void Put(long long x, char c = -1) {
  if (x < 0) putchar('-'), x = -x;
  Put1(x);
  if (c >= 0) putchar(c);
}
template <typename T>
T Max(T x, T y) {
  return x > y ? x : y;
}
template <typename T>
T Min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
T Abs(T x) {
  return x < 0 ? -x : x;
}
int head[MAXN], tot;
struct edge {
  int v, nxt;
} e[MAXN << 1];
void Add_Edge(int x, int y) {
  e[++tot].v = y;
  e[tot].nxt = head[x];
  head[x] = tot;
}
void Add_Double_Edge(int x, int y) {
  Add_Edge(x, y);
  Add_Edge(y, x);
}
struct Edge {
  int u, v, w, ID;
  Edge() {}
  Edge(int u1, int v1, int w1, int ID1) {
    u = u1;
    v = v1;
    w = w1;
    ID = ID1;
  }
  bool operator<(const Edge &px) const { return w < px.w; }
} E[MAXN];
int l[MAXN], r[MAXN], T;
void dfs(int x, int fa) {
  l[x] = n;
  bool son = 1;
  for (int i = head[x]; i; i = e[i].nxt)
    if (e[i].v != fa) {
      dfs(e[i].v, x);
      son = 0;
      l[x] = Min(l[x], l[e[i].v]);
      r[x] = Max(r[x], r[e[i].v]);
    }
  if (son) l[x] = r[x] = ++T;
  E[x] = Edge(l[x], r[x] + 1, a[x], x);
}
int f[MAXN];
int findSet(int x) {
  if (f[x] != x) f[x] = findSet(f[x]);
  return f[x];
}
int main() {
  n = Read();
  for (int i = 1; i <= n; ++i) a[i] = Read();
  for (int i = 1; i < n; ++i) Add_Double_Edge(Read(), Read());
  dfs(1, 0);
  sort(E + 1, E + n + 1);
  for (int i = 1; i <= T + 1; ++i) f[i] = i;
  int S = 0, R;
  for (int L = 1; L <= n; L = R + 1) {
    R = L;
    while (R < n && E[R + 1].w == E[R].w) R++;
    for (int i = L; i <= R; ++i) {
      if (findSet(E[i].u) != findSet(E[i].v)) vis[E[i].ID] = 1, S++;
    }
    for (int i = L; i <= R; ++i) {
      int u = findSet(E[i].u), v = findSet(E[i].v);
      if (u != v) {
        f[u] = v;
        ans += E[i].w;
      }
    }
  }
  Put(ans, ' ');
  Put(S, '\n');
  for (int i = 1; i <= n; ++i)
    if (vis[i]) Put(i, ' ');
  return 0;
}
