#include <bits/stdc++.h>
using namespace std;
long long ans[200020][2];
bool TT[200020];
vector<int> bst[200020][2];
vector<int> g[200020];
int c[200020];
vector<int> res;
void dfs(int p, int u) {
  long long sum = 0;
  for (int i = 0; i < g[u].size(); i++) {
    if (g[u][i] == p) continue;
    dfs(u, g[u][i]);
    sum += ans[g[u][i]][1];
  }
  ans[u][1] = sum;
  ans[u][0] = 1000000000000000LL;
  for (int i = 0; i < g[u].size(); i++)
    if (g[u][i] != p) {
      long long WITH = sum - ans[g[u][i]][1] + ans[g[u][i]][0];
      if (ans[u][0] > WITH) {
        ans[u][0] = WITH;
        bst[u][0].clear();
        bst[u][0].push_back(g[u][i]);
      } else if (ans[u][0] == WITH)
        bst[u][0].push_back(g[u][i]);
      if (ans[u][1] > WITH + c[u]) {
        ans[u][1] = WITH + c[u];
        bst[u][1].clear();
        bst[u][1].push_back(g[u][i]);
      } else if (ans[u][1] == WITH + c[u])
        bst[u][1].push_back(g[u][i]);
    }
  if (sum == ans[u][1]) TT[u] = 1;
  if (g[u].size() == 1 && u != 1) {
    ans[u][1] = c[u];
    ans[u][0] = 0;
  }
}
bool f[200020][2];
bool can[200020];
bool iis[400020];
void print(int p, int u, int cc) {
  if (iis[2 * u + cc]) return;
  iis[2 * u + cc] = 1;
  if (g[u].size() == 1 && u != 1) {
    if (cc == 1) can[u] = 1;
    return;
  }
  if (cc == 1 && bst[u][cc].size() > 0) can[u] = 1;
  for (int i = 0; i < bst[u][cc].size(); i++) print(u, bst[u][cc][i], 0);
  if (bst[u][cc].size() == 0 || bst[u][cc].size() >= 2 || (TT[u] && cc == 1)) {
    for (int i = 0; i < g[u].size(); i++)
      if (g[u][i] != p) print(u, g[u][i], 1);
    return;
  }
  for (int i = 0; i < g[u].size(); i++)
    if (g[u][i] != p && g[u][i] != bst[u][cc][0]) print(u, g[u][i], 1);
}
int n, i, a, b;
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (i = 1; i < n; i++) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(0, 1);
  print(0, 1, 1);
  cout << ans[1][1] << " ";
  for (int i = 1; i <= n; i++)
    if (can[i]) res.push_back(i);
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); i++) cout << res[i] << " ";
  cout << endl;
}
