#include <bits/stdc++.h>
using namespace std;
const long long N = 200010;
struct edge {
  long long from, to, val, num;
} e[N];
long long n, cnt, leafcnt, edgecnt, valsum, l[N], r[N], fa[N], rfa[N], du[N],
    used[N];
vector<long long> q[N], leaf;
queue<long long> jiaran;
inline bool cmp(edge e1, edge e2) { return e1.val < e2.val; }
void dfs(long long x, long long nfa) {
  rfa[x] = nfa;
  if (q[x].size() == 1 && nfa) {
    leafcnt++;
    l[x] = r[x] = leafcnt;
    leaf.push_back(x);
    return;
  }
  for (long long i = 0; i < q[x].size(); ++i) {
    if (q[x][i] == nfa) continue;
    dfs(q[x][i], x);
  }
}
inline void topu() {
  for (long long i = 0; i < leaf.size(); ++i) jiaran.push(leaf[i]);
  while (!jiaran.empty()) {
    long long x = jiaran.front();
    jiaran.pop();
    r[rfa[x]] = max(r[rfa[x]], r[x]);
    l[rfa[x]] = min(l[rfa[x]], l[x]);
    du[rfa[x]]--;
    if (du[rfa[x]] == 1) jiaran.push(rfa[x]);
  }
}
long long find(long long x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
inline long long read() {
  long long ret = 0;
  char ch;
  while ((ch = getchar()) > '9' || ch < '0')
    ;
  ret = ch - '0';
  while ((ch = getchar()) >= '0' && ch <= '9')
    ret = (ret << 1) + (ret << 3) + ch - '0';
  return ret;
}
signed main() {
  n = read();
  for (long long i = 1; i <= n; ++i) e[i].val = read(), fa[i] = i;
  fa[n + 1] = n + 1;
  memset(l, 0x3f, sizeof(l));
  for (long long i = 1; i < n; ++i) {
    long long x, y;
    x = read();
    y = read();
    q[x].push_back(y);
    q[y].push_back(x);
    du[x]++;
    du[y]++;
  }
  dfs(1, 0);
  topu();
  for (long long i = 1; i <= n; ++i)
    e[i].from = l[i], e[i].to = r[i] + 1, e[i].num = i;
  sort(e + 1, e + 1 + n, cmp);
  long long last = 1, cntans = 0;
  e[n + 1].val = -114514;
  for (long long i = 1; i <= n; ++i) {
    if (e[i + 1].val != e[last].val) {
      for (long long j = last; j <= i; ++j) {
        if (find(e[j].from) != find(e[j].to)) used[++cntans] = e[j].num;
      }
      for (long long j = last; j <= i; ++j) {
        if (find(e[j].from) != find(e[j].to)) {
          fa[find(e[j].from)] = find(e[j].to);
          edgecnt++;
          valsum += e[i].val;
        }
      }
      last = i + 1;
      if (edgecnt == leafcnt) break;
    }
  }
  cout << valsum << ' ' << cntans << endl;
  sort(used + 1, used + 1 + cntans);
  for (long long i = 1; i <= cntans; ++i) printf("%d ", used[i]);
  cout << endl;
  return 0;
}
