#include <bits/stdc++.h>
using namespace std;
const long long M = 1000000007, N = 1000000009;
int n, i, j, c[200005], head[200005], Next[400005], adj[400005], f[200005], u,
    vv, s[200005], v[200005], p[200005], k;
int fa[200005], mx[200005];
long long ans;
void Push(int u, int v) {
  Next[++k] = head[u];
  head[u] = k;
  adj[k] = v;
}
struct str {
  int c, x;
} a[200005];
bool cmp(str a, str b) { return a.c < b.c; }
void dfs(int i, int f) {
  int j;
  fa[i] = f;
  for (j = head[i]; j != 0; j = Next[j])
    if (adj[j] != f) {
      s[i]++;
      dfs(adj[j], i);
    }
}
void mark(int i, int u) {
  if (i == 0) return;
  if (s[i] == 0) {
    if (v[i] == 1) return;
    v[i] = 1;
    mx[i] = u;
    s[fa[i]]--;
    if (v[fa[i]] == 0) mark(fa[i], u);
  }
  if (v[fa[i]] == 1 && s[fa[i]] == 1) mark(fa[i], u);
  int j;
  if (v[i] == 1 && s[i] == 1) {
    s[i]--;
    for (j = head[i]; j != 0; j = Next[j])
      if (v[adj[j]] == 0 && adj[j] != fa[i]) {
        v[adj[j]] = 1;
        mx[adj[j]] = u;
        mark(adj[j], u);
      }
  }
}
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &c[i]);
    a[i] = (str){c[i], i};
  }
  sort(a + 1, a + 1 + n, cmp);
  for (i = 1; i < n; i++) {
    scanf("%d %d", &u, &vv);
    Push(u, vv);
    Push(vv, u);
  }
  dfs(1, 0);
  k = 0;
  for (i = 1; i <= n; i++)
    if (v[a[i].x] == 0) {
      p[++k] = a[i].x;
      ans += a[i].c;
      v[a[i].x] = 1;
      s[fa[a[i].x]]--;
      mx[a[i].x] = a[i].c;
      mark(fa[a[i].x], a[i].c);
      mark(a[i].x, a[i].c);
    } else if (mx[a[i].x] == a[i].c)
      p[++k] = a[i].x;
  cout << ans << ' ' << k << endl;
  sort(p + 1, p + 1 + k);
  for (i = 1; i <= k; i++) printf("%d ", p[i]);
}
