#include <bits/stdc++.h>
using namespace std;
long long n, vis[2000001], c[4000001], b[2000001], ctop, s, ans, tot,
    fa[2000001], vis3[2000001];
struct node {
  long long x, y, z, id;
} a[2000001];
vector<long long> g[2000001];
bool cmp(const node &a, const node &b) {
  if (a.z != b.z) return a.z < b.z;
}
long long find(long long x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
void dfs(long long x, long long pre) {
  if (g[x].size() == 1 && g[x][0] == pre) {
    c[++ctop] = x;
    b[x] = ctop;
    a[x].x = x;
    a[x].y = x;
    return;
  }
  for (long long i = 0; i < g[x].size(); i++) {
    if (g[x][i] != pre) {
      dfs(g[x][i], x);
      if (!a[x].x) a[x].x = a[g[x][i]].x;
      a[x].y = a[g[x][i]].y;
    }
  }
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i].z;
  for (long long i = 1; i < n; i++) {
    long long a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, -1);
  for (long long i = 1; i <= n; i++)
    a[i].x = c[b[a[i].x] - 1], fa[i] = i, a[i].id = i;
  sort(a + 1, a + n + 1, cmp);
  long long j = 1;
  for (long long i = 1; i <= n; i++) {
    if (ans <= ctop) {
      for (j = max(i, j); a[i].z == a[j].z; j++) {
        if (find(a[j].x) != find(a[j].y) && !vis3[a[j].id])
          s++, vis3[a[j].id] = 1;
      }
      if (find(a[i].x) != find(a[i].y)) {
        vis[a[i].id] = 1;
        ans++;
        tot += a[i].z;
        fa[find(a[i].x)] = find(a[i].y);
      }
    } else
      break;
  }
  cout << tot << " " << s << endl;
  for (long long i = 1; i <= n; i++)
    if (vis[i] || vis3[i]) cout << i << " ";
}
