#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, op;
long long a[N], f[N][2], mintmp[N];
bool up[N], cu[N], ans[N];
vector<int> e[N];
void dfs(int u, int fa) {
  if (u != 1 && e[u].size() == 1) {
    f[u][0] = 0, f[u][1] = a[u];
    return;
  }
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (v == fa) continue;
    dfs(v, u);
    f[u][1] += f[v][1];
    mintmp[u] = min(-f[v][1] + f[v][0], mintmp[u]);
  }
  f[u][0] = f[u][1] + mintmp[u];
  if (f[u][1] >= f[u][0] + a[u]) up[u] = 1;
  if (f[u][1] > f[u][0] + a[u]) cu[u] = 1, f[u][1] = f[u][0] + a[u];
}
void dfs2(int u, int fa, bool ok0, bool ok1) {
  if (u != 1 && e[u].size() == 1) {
    if (ok1) ans[u] = 1;
    return;
  }
  int cnt = 0;
  bool flg = (ok0 || (ok1 && up[u]));
  bool ct = f[u][0] + a[u] > f[u][1];
  if (up[u] && ok1) ans[u] = 1;
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (v == fa) continue;
    if (-f[v][1] + f[v][0] == mintmp[u]) cnt++;
  }
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (v == fa) continue;
    bool _ok0 = (-f[v][1] + f[v][0] == mintmp[u]);
    bool __ok0 = (cnt > 1 || !_ok0);
    dfs2(v, u, _ok0 && flg,
         (__ok0 && ok0) || ((!cu[u] && ok1) || (!ct && __ok0)));
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(1, 0);
  cout << f[1][1] << ' ';
  dfs2(1, 0, 0, 1);
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (ans[i]) cnt++;
  cout << cnt << endl;
  for (int i = 1; i <= n; i++)
    if (ans[i]) cout << i << ' ';
  return 0;
}
