#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, tot, cnt;
long long ans;
int a[N], st[N], ed[N], f[N], dep[N], lg[N], head[N], vis[N], to[N << 1],
    nxt[N << 1], val[N << 1], ffa[N][19], mx[N][19];
vector<int> vv, e[N];
struct Edge {
  int u, v, w, id;
  bool operator<(const Edge &op) const { return w < op.w; }
} edg[N];
void dfs(int u, int fa) {
  int sz = e[u].size();
  for (int i = 0; i < sz; i++) {
    int v = e[u][i];
    if (v == fa) continue;
    dfs(v, u);
    if (!st[u] && !ed[u])
      st[u] = st[v], ed[u] = ed[v];
    else
      st[u] = min(st[u], st[v]), ed[u] = max(ed[u], ed[v]);
  }
  if (sz == 1 && u != 1) st[u] = ed[u] = ++tot;
}
inline int find(int x) { return f[x] = (f[x] == x) ? f[x] : find(f[x]); }
inline void add(int u, int v, int w) {
  to[++cnt] = v, nxt[cnt] = head[u], head[u] = cnt, val[cnt] = w;
}
void dfs1(int u, int fa) {
  dep[u] = dep[fa] + 1;
  for (int i = 1; i <= lg[dep[u]]; i++)
    ffa[u][i] = ffa[ffa[u][i - 1]][i - 1],
    mx[u][i] = max(mx[u][i - 1], mx[ffa[u][i - 1]][i - 1]);
  for (int i = head[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == fa) continue;
    ffa[v][0] = u, mx[v][0] = val[i];
    dfs1(v, u);
  }
}
int ask(int x, int y) {
  int res = 0;
  while (dep[x] != dep[y]) {
    if (dep[x] < dep[y]) swap(x, y);
    int tp = lg[dep[x] - dep[y]];
    res = max(res, mx[x][tp]), x = ffa[x][tp];
  }
  if (x == y) return res;
  for (int i = lg[dep[x]]; i >= 0; i--)
    if (ffa[x][i] != ffa[y][i]) {
      res = max(res, max(mx[x][i], mx[y][i]));
      x = ffa[x][i], y = ffa[y][i];
    }
  res = max(res, max(mx[x][0], mx[y][0]));
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    e[x].push_back(y), e[y].push_back(x);
  }
  dfs(1, 0);
  for (int i = 1; i <= n; i++) edg[i] = (Edge){st[i], ed[i] + 1, a[i], i};
  ++tot;
  for (int i = 1; i <= tot; i++) f[i] = i;
  sort(edg + 1, edg + n + 1);
  for (int i = 1, sum = 0; (i <= n && sum < tot - 1); i++) {
    int fx = find(edg[i].u), fy = find(edg[i].v);
    if (fx != fy) {
      f[fy] = fx, sum++, ans += edg[i].w, vv.push_back(edg[i].id), vis[i] = 1;
      add(edg[i].u, edg[i].v, edg[i].w), add(edg[i].v, edg[i].u, edg[i].w);
    }
  }
  for (int i = 2; i <= tot; i++) lg[i] = lg[i >> 1] + 1;
  dfs1(1, 0);
  for (int i = 1; i <= n; i++)
    if (!vis[i]) {
      if (ask(edg[i].u, edg[i].v) == edg[i].w) vv.push_back(edg[i].id);
    }
  sort(vv.begin(), vv.end());
  int sz = vv.size();
  printf("%lld %d\n", ans, sz);
  for (int i = 0; i < sz; i++) printf("%d ", vv[i]);
  puts("");
}
