#include <bits/stdc++.h>
using namespace std;
const int MN = 200005, inf = 1000000005, mod = 1000000007;
const long long INF = 1000000000000000005LL;
int lis;
int lewy[MN], prawy[MN], used[MN], C[MN];
int rep[MN], ile[MN];
map<int, vector<int> > E;
vector<int> G[MN];
void dfs(int x) {
  used[x] = 1;
  lewy[x] = inf;
  for (auto v : G[x])
    if (!used[v]) {
      dfs(v);
      lewy[x] = min(lewy[x], lewy[v]);
      prawy[x] = max(prawy[x], prawy[v]);
    }
  if (lewy[x] == inf) lewy[x] = prawy[x] = ++lis;
}
int Find(int a) {
  if (a == rep[a]) return a;
  return (rep[a] = Find(rep[a]));
}
void Union(int a, int b) {
  a = Find(a), b = Find(b);
  if (a == b) return;
  if (ile[a] > ile[b]) {
    ile[a] += ile[b];
    rep[b] = a;
  } else {
    ile[b] += ile[a];
    rep[a] = b;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &C[i]);
  for (int i = 1; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1);
  for (int i = 1; i <= lis + 1; ++i) {
    rep[i] = i;
    ile[i] = 1;
  }
  for (int i = 1; i <= n; ++i) E[C[i]].push_back(i);
  long long suma = 0LL;
  vector<int> ans;
  for (auto &c : E) {
    for (auto v : c.second)
      if (Find(lewy[v]) != Find(prawy[v] + 1)) ans.push_back(v);
    for (auto v : c.second)
      if (Find(lewy[v]) != Find(prawy[v] + 1)) {
        Union(lewy[v], prawy[v] + 1);
        suma += c.first;
      }
  }
  printf("%lld %d\n", suma, (int)ans.size());
  sort(ans.begin(), ans.end());
  for (auto v : ans) printf("%d ", v);
}
