#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  x = 0;
  int f(1);
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  x *= f;
}
template <typename T, typename... Args>
inline void read(T &x, Args &...args) {
  read(x);
  read(args...);
}
template <typename T>
void write(T x, char f = '\n') {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10, '\0');
  putchar('0' + x % 10);
  if (f != '\0') putchar(f);
}
const int maxn = 200005;
int n, A[maxn], R[maxn], vis[maxn];
int tot, L[maxn], fa[maxn];
struct EDGE {
  int u, v, l, id;
} E[maxn];
bool operator<(const EDGE &x, const EDGE &y) { return x.l < y.l; }
vector<int> T[maxn];
void Dfs(int x, int fa) {
  int leaf = 1;
  L[x] = n + 1;
  for (auto y : T[x]) {
    if (y == fa) continue;
    leaf = 0;
    Dfs(y, x);
    L[x] = min(L[x], L[y]);
    R[x] = max(R[x], R[y]);
  }
  if (leaf) L[x] = R[x] = ++tot;
}
int find(int x) { return fa[x] == x ? x : fa[x] = find(fa[x]); }
int main() {
  read(n);
  for (int i(1); i <= n; ++i) read(A[i]);
  for (int i(1); i < n; ++i) {
    int u, v;
    read(u, v);
    T[u].emplace_back(v);
    T[v].emplace_back(u);
  }
  Dfs(1, 0);
  for (int i(1); i <= n; ++i) E[i] = (EDGE){L[i], R[i] + 1, A[i], i};
  sort(E + 1, E + 1 + n);
  for (int i(1); i <= tot + 1; ++i) fa[i] = i;
  long long ANS = 0;
  int cnt = 0;
  for (int L = 1, R; L <= n; L = R + 1) {
    R = L;
    while (R <= n && E[R].l == E[L].l) ++R;
    --R;
    for (int i = L; i <= R; ++i) {
      int u = find(E[i].u), v = find(E[i].v);
      if (u != v) vis[E[i].id] = 1, ++cnt;
    }
    for (int i = L; i <= R; ++i) {
      int u = find(E[i].u), v = find(E[i].v);
      if (u == v) continue;
      fa[v] = u;
      ANS += 1LL * E[i].l;
    }
  }
  write(ANS, ' ');
  write(cnt);
  for (int i(1); i <= n; ++i)
    if (vis[i]) write(i, ' ');
  puts("");
  return 0;
}
