#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
ll mod(ll a, ll b) { return ((a % b) + b) % b; }
int cmp(double x, double y = 0, double tol = 1.e-7) {
  return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}
vll cost;
vvi tree;
vector<pair<ll, ll>> ans;
vi which;
void compute(int node, int par) {
  ll best_delta = 0;
  ll sum_first = 0;
  ll cnt_children = 0;
  for (int x : tree[node])
    if (x != par) {
      compute(x, node);
      sum_first += ans[x].first;
      best_delta = max(best_delta, ans[x].first - ans[x].second);
      cnt_children++;
    }
  if (cnt_children == 0)
    ans[node] = {cost[node], 0};
  else
    ans[node] = {min(sum_first, sum_first - best_delta + cost[node]),
                 sum_first - best_delta};
}
vb done_which_true, done_which_false;
void find_which(int node, int par, bool cover_all) {
  if (cover_all && done_which_true[node]) return;
  if (!cover_all && done_which_false[node]) return;
  if (cover_all)
    done_which_true[node] = true;
  else
    done_which_false[node] = true;
  ll best_delta = 0;
  ll sum_first = 0;
  ll cnt_children = 0;
  vi child_best_deltas;
  for (int x : tree[node])
    if (x != par) {
      sum_first += ans[x].first;
      if (ans[x].first - ans[x].second > best_delta) {
        child_best_deltas.clear();
        best_delta = ans[x].first - ans[x].second;
      }
      if (ans[x].first - ans[x].second == best_delta) {
        child_best_deltas.push_back(x);
      }
      cnt_children++;
    }
  if (cover_all) {
    if (cnt_children == 0) {
      which.push_back(node);
    } else {
      if (sum_first == ans[node].first)
        for (int x : tree[node])
          if (x != par) find_which(x, node, true);
      if (sum_first - best_delta + cost[node] == ans[node].first) {
        which.push_back(node);
        if (child_best_deltas.size() == 1) {
          int child_best_delta = child_best_deltas[0];
          for (int x : tree[node])
            if (x != par) find_which(x, node, x != child_best_delta);
        } else {
          for (int x : tree[node])
            if (x != par) find_which(x, node, true);
          for (int x : child_best_deltas) find_which(x, node, false);
        }
      }
    }
  } else {
    if (cnt_children != 0) {
      if (child_best_deltas.size() == 1) {
        int child_best_delta = child_best_deltas[0];
        for (int x : tree[node])
          if (x != par) find_which(x, node, x != child_best_delta);
      } else {
        for (int x : tree[node])
          if (x != par) find_which(x, node, true);
        for (int x : child_best_deltas) find_which(x, node, false);
      }
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  cost = vll(n);
  for (ll &x : cost) scanf("%lld", &x);
  tree = vvi(n);
  for (auto _ = 0; _ < n - 1; ++_) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  ans.resize(n);
  compute(0, -1);
  printf("%lld", ans[0].first);
  which.clear();
  done_which_true.assign(n, false);
  done_which_false.assign(n, false);
  find_which(0, -1, true);
  sort((which).begin(), (which).end());
  which.erase(unique((which).begin(), (which).end()), which.end());
  printf(" %d\n", (int)which.size());
  for (int x : which) printf("%d ", x + 1);
  printf("\n");
  return 0;
}
