#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& t) {
  return in >> t.first >> t.second;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& t) {
  return out << t.first << " " << t.second;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& t) {
  for (long long i = 0; i < t.size(); i++) in >> t[i];
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& t) {
  for (long long i = 0; i < t.size(); i++) out << t[i] << " ";
  return out;
}
struct G {
  vector<long long> to;
  long long p;
};
vector<G> g;
const long long N = 2e5 + 5;
long long dp[N][2][2];
long long is[N][2][2];
void upd(pair<long long, long long>& m1, pair<long long, long long>& m2,
         long long val, long long i) {
  if (val >= m2.first)
    m1 = m2, m2 = {val, i};
  else if (val > m1.first)
    m1 = {val, i};
}
void dfs1(long long v, long long p) {
  if (g[v].to.size() == 1 && p != -1) {
    dp[v][0][1] = 0;
    dp[v][0][0] = 1e15;
    dp[v][1][0] = g[v].p;
    return;
  }
  pair<long long, long long> dmax1 = {-1, -1}, dmax2 = {-1, -1};
  long long sum_full = 0;
  for (long long u : g[v].to) {
    if (u == p) continue;
    dfs1(u, v);
    long long t;
    sum_full += t = min(dp[u][0][0], dp[u][1][0]);
    upd(dmax2, dmax1, t - dp[u][0][1], u);
  }
  dp[v][0][0] = sum_full;
  if (dmax1.first != -1)
    dp[v][1][0] = (dp[v][0][1] = sum_full - dmax1.first) + g[v].p;
  else
    dp[v][0][1] = dp[v][1][0] = 1e15;
}
void dfs2(long long v, long long p) {
  pair<long long, long long> dmax1 = {-1, -1}, dmax2 = {-1, -1};
  long long sum_full = 0;
  for (long long u : g[v].to) {
    if (u == p) continue;
    long long t;
    sum_full += t = min(dp[u][0][0], dp[u][1][0]);
    upd(dmax2, dmax1, t - dp[u][0][1], u);
  }
  long long dmax1cnt = 0;
  long long dmax2cnt = 0;
  for (long long u : g[v].to) {
    if (u == p) continue;
    long long t = min(dp[u][0][0], dp[u][1][0]);
    dmax1cnt += dmax1.first == t - dp[u][0][1];
    dmax2cnt += dmax2.first == t - dp[u][0][1];
  }
  if (is[v][0][0]) {
    for (long long u : g[v].to) {
      if (u == p) continue;
      long long t = min(dp[u][0][0], dp[u][1][0]);
      is[u][0][0] = t == dp[u][0][0];
      is[u][1][0] = t == dp[u][1][0];
    }
  }
  if (is[v][1][0] || is[v][0][1]) {
    for (long long u : g[v].to) {
      if (u == p) continue;
      long long t = min(dp[u][0][0], dp[u][1][0]);
      if (t - dp[u][0][1] == dmax1.first) is[u][0][1] = 1;
      if (dmax1cnt != 1 || dmax1cnt == 1 && !is[u][0][1]) {
        is[u][0][0] = t == dp[u][0][0];
        is[u][1][0] = t == dp[u][1][0];
      }
    }
  }
  for (long long u : g[v].to)
    if (u == p)
      continue;
    else
      dfs2(u, v);
}
signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long rrrr = 1e9 + 2;
  long long n;
  cin >> n;
  g.resize(n);
  for (long long i = 0; i < n; ++i) cin >> g[i].p;
  for (long long i = 1; i < n; ++i) {
    long long a, b;
    cin >> a >> b;
    --a, --b;
    g[a].to.push_back(b);
    g[b].to.push_back(a);
  }
  dfs1(0, -1);
  for (long long i = 0; i < n; ++i) {
  }
  long long t;
  cout << (t = min(dp[0][0][0], dp[0][1][0])) << " ";
  is[0][0][0] = dp[0][0][0] == t;
  is[0][1][0] = dp[0][1][0] == t;
  dfs2(0, -1);
  vector<long long> ans;
  for (long long i = 0; i < n; ++i) {
    if (is[i][1][0] || is[i][1][1]) ans.push_back(i + 1);
  }
  cout << ans.size() << endl << ans;
  return 0;
}
