#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 233;
long long dp[maxn][2];
int a[maxn];
int n;
vector<int> G[maxn];
void dfs1(int u, int f) {
  if (G[u].size() == 1 && u != 1) {
    dp[u][0] = a[u];
    dp[u][1] = 0;
    return;
  }
  long long sum = 0;
  long long mn = 1e18;
  for (auto v : G[u]) {
    if (v == f) continue;
    dfs1(v, u);
    sum += dp[v][0];
    mn = min(mn, dp[v][1] - dp[v][0]);
  }
  dp[u][1] = sum + mn;
  dp[u][0] = min(sum, dp[u][1] + a[u]);
}
bool vis[maxn][2];
void dfs2(int u, int c, int f, vector<int> &res) {
  if (vis[u][c]) return;
  vis[u][c] = 1;
  if (G[u].size() == 1 && u != 1) {
    if (c == 0) res.emplace_back(u);
    return;
  }
  long long sum = 0;
  long long mn = 1e18;
  vector<int> p;
  for (auto v : G[u]) {
    if (v == f) continue;
    sum += dp[v][0];
    if (mn > dp[v][1] - dp[v][0]) {
      mn = min(mn, dp[v][1] - dp[v][0]);
      p.clear();
      p.emplace_back(v);
    } else if (mn == dp[v][1] - dp[v][0]) {
      p.emplace_back(v);
    }
  }
  if (c == 0) {
    if (dp[u][0] == sum) {
      for (auto v : G[u]) {
        if (v == f) continue;
        dfs2(v, 0, u, res);
      }
    }
    if (dp[u][0] == dp[u][1] + a[u]) {
      res.emplace_back(u);
      if (p.size() == 1) {
        for (auto v : G[u]) {
          if (v == f || v == p[0]) continue;
          dfs2(v, 0, u, res);
        }
        dfs2(p[0], 1, u, res);
      } else {
        for (auto v : G[u]) {
          if (v == f) continue;
          dfs2(v, 0, u, res);
        }
        for (auto v : p) {
          dfs2(v, 1, u, res);
        }
      }
    }
  } else {
    if (p.size() == 1) {
      for (auto v : G[u]) {
        if (v == f || v == p[0]) continue;
        dfs2(v, 0, u, res);
      }
      dfs2(p[0], 1, u, res);
    } else {
      for (auto v : G[u]) {
        if (v == f) continue;
        dfs2(v, 0, u, res);
      }
      for (auto v : p) {
        dfs2(v, 1, u, res);
      }
    }
  }
}
int main() {
  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;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  dfs1(1, 0);
  cout << dp[1][0] << " ";
  vector<int> res;
  dfs2(1, 0, 0, res);
  sort(res.begin(), res.end());
  res.erase(unique(res.begin(), res.end()), res.end());
  cout << res.size() << "\n";
  for (auto it : res) cout << it << " ";
  cout << "\n";
  return 0;
}
