#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, fh = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') fh = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + ch - '0';
    ch = getchar();
  }
  return x * fh;
}
const int N = 2e5 + 5;
struct Edge {
  int to, next;
} e[N << 1];
int head[N], tot, n, w[N], f[N], u[N], v[N], ans[N], top, leaf[N], rk[N], od[N],
    mx[N];
void connect(int x, int y) {
  e[++tot] = (Edge){y, head[x]};
  head[x] = tot;
}
void dfs(int now, int from) {
  od[now] = now;
  u[now] = 1e9;
  int rp = 0;
  for (int i = head[now]; i; i = e[i].next) {
    int p = e[i].to;
    if (p == from) continue;
    rp++;
    dfs(p, now);
    u[now] = min(u[now], u[p]);
    v[now] = max(v[now], v[p]);
  }
  if (!rp) leaf[++top] = now, rk[now] = u[now] = v[now] = top;
}
bool cmp(int x, int y) { return w[x] < w[y]; }
int fin(int x) {
  if (x == f[x]) return x;
  return f[x] = fin(f[x]);
}
void kruskal() {
  for (register int i = 1; i <= top + 1; ++i) f[i] = i;
  top = 0;
  sort(od + 1, od + 1 + n, cmp);
  long long cost = 0;
  for (register int i = 1; i <= n; ++i) {
    int x = u[od[i]], y = v[od[i]] + 1;
    int fx = fin(x), fy = fin(y), R = i;
    if (fx != fy) ans[++top] = od[i];
    while (R < n && w[od[R + 1]] == w[od[R]]) {
      R++;
      int x = u[od[R]], y = v[od[R]] + 1;
      int fx = fin(x), fy = fin(y);
      if (fx != fy) ans[++top] = od[R];
    }
    for (register int j = i; j <= R; ++j) {
      int x = u[od[j]], y = v[od[j]] + 1;
      int fx = fin(x), fy = fin(y);
      if (fx == fy) continue;
      f[fx] = fy;
      cost += w[od[j]];
    }
    i = R;
  }
  cout << cost << " " << top << endl;
  sort(ans + 1, ans + 1 + top);
  for (register int i = 1; i <= top; ++i) printf("%d ", ans[i]);
  puts("");
}
int main() {
  n = read();
  for (register int i = 1; i <= n; ++i) w[i] = read();
  for (register int i = 1; i <= n - 1; ++i) {
    int x = read(), y = read();
    connect(x, y);
    connect(y, x);
  }
  dfs(1, 0);
  kruskal();
  return 0;
}
