#include <bits/stdc++.h>
using namespace std;
int n;
int A[200006], deg[200006];
vector<int> G[200006];
struct ed {
  int u, v, w, id;
} E[200006];
int id;
int dfn[200006], clo;
void dfs(int u, int fa) {
  dfn[u] = clo + 1;
  if (u != 1 && deg[u] == 1) ++clo;
  for (int v : G[u])
    if (v != fa) dfs(v, u);
  E[++id] = {dfn[u], clo + 1, A[u], u};
}
bool cmp(ed u, ed v) { return u.w < v.w; }
int fa[200006];
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
void solve() {
  cin >> n;
  for (int i = (1), iend = (n); i <= iend; ++i) scanf("%d", A + i);
  int u, v;
  for (int i = (2), iend = (n); i <= iend; ++i)
    scanf("%d%d", &u, &v), G[u].push_back(v), G[v].push_back(u), ++deg[u],
        ++deg[v];
  dfs(1, 1);
  sort(E + 1, E + 1 + n, cmp);
  for (int i = (1), iend = (clo + 1); i <= iend; ++i) fa[i] = i;
  long long ans = 0;
  vector<int> re;
  for (int i = 1, j; i <= n; i = j) {
    j = i;
    while (j != n + 1 && E[j].w == E[i].w) {
      u = find(E[j].u), v = find(E[j].v);
      if (u != v) re.push_back(E[j].id);
      ++j;
    }
    for (int k = (i), kend = (j - 1); k <= kend; ++k) {
      u = find(E[k].u), v = find(E[k].v);
      if (u != v) fa[u] = v, ans += E[k].w;
    }
  }
  cout << ans << ' ' << re.size() << endl;
  sort((re).begin(), (re).end());
  for (int i : re) printf("%d ", i);
}
signed main() { solve(); }
