#include <bits/stdc++.h>
using namespace std;
mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T>
void chkmax(T& x, T y) {
  if (x < y) x = y;
}
template <typename T>
void chkmin(T& x, T y) {
  if (x > y) x = y;
}
inline int read() {
  int x = 0;
  char c = getchar();
  while (c < 48) c = getchar();
  while (c > 47) x = x * 10 + (c ^ 48), c = getchar();
  return x;
}
const int maxn = 2e5 + 10;
int n, A[maxn];
vector<int> G[maxn];
int tot, L[maxn], R[maxn];
void dfs(int u, int f) {
  L[u] = tot;
  for (int v : G[u])
    if (v != f) dfs(v, u);
  R[u] = (tot += u > 1 && (int)G[u].size() == 1);
}
int par[maxn];
int find(int x) { return par[x] == x ? x : par[x] = find(par[x]); }
struct edge {
  int u, v, w, tid;
} E[maxn];
void solve() {
  cin >> n;
  for (int i = (1), iend = (n); i <= iend; ++i) A[i] = read(), par[i] = i;
  for (int i = (2), iend = (n); i <= iend; ++i) {
    int u = read(), v = read();
    G[u].push_back(v), G[v].push_back(u);
  }
  dfs(1, 0);
  for (int i = (1), iend = (n); i <= iend; ++i) {
    E[i] = {L[i], R[i], A[i], i};
  }
  sort(E + 1, E + n + 1, [](edge P, edge Q) { return P.w < Q.w; });
  long long ans = 0;
  vector<int> vec;
  for (int i = (1), iend = (n); i <= iend; ++i) {
    int j = i;
    while (j < n && E[j + 1].w == E[i].w) j++;
    for (int k = (i), kend = (j); k <= kend; ++k) {
      int u = E[k].u, v = E[k].v;
      if (find(u) != find(v)) vec.push_back(E[k].tid);
    }
    for (int k = (i), kend = (j); k <= kend; ++k) {
      int u = E[k].u, v = E[k].v;
      if (find(u) != find(v)) {
        par[find(u)] = find(v), ans += E[k].w;
      }
    }
    i = j;
  }
  cout << ans << ' ' << (int)vec.size() << endl;
  sort(vec.begin(), vec.end());
  for (int x : vec) printf("%d ", x);
}
signed main() {
  solve();
  return 0;
}
