#include <bits/stdc++.h>
using namespace std;
vector<int> c;
vector<vector<int>> tree;
int nlist = 1;
vector<pair<pair<int, int>, pair<int, int>>> edges;
pair<int, int> dfs(int v, int prev = -1) {
  if (tree[v].size() == 1 && prev != -1) {
    edges.push_back({{c[v], v}, {nlist, nlist + 1}});
    return {nlist, nlist++};
  }
  int l = nlist, r = nlist;
  for (int u : tree[v]) {
    if (u == prev) continue;
    auto p = dfs(u, v);
    l = min(l, p.first);
    r = max(r, p.second);
  }
  edges.push_back({{c[v], v}, {l, r + 1}});
  return {l, r};
}
vector<int> par;
vector<int> ran;
int get(int a) {
  if (a == par[a]) return a;
  return par[a] = get(par[a]);
}
void merge(int a, int b) {
  a = get(a);
  b = get(b);
  if (ran[a] > ran[b]) {
    par[b] = a;
  } else if (ran[b] > ran[a]) {
    par[a] = b;
  } else {
    ran[a]++;
    par[b] = a;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  int n;
  cin >> n;
  c.resize(n + 1);
  tree.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    tree[u].push_back(v);
    tree[v].push_back(u);
  }
  dfs(1);
  par.resize(nlist + 1);
  ran.resize(nlist + 1, 1);
  for (int i = 0; i <= nlist; i++) {
    par[i] = i;
  }
  sort(edges.begin(), edges.end());
  long long ans = 0;
  vector<int> pos;
  for (int i = 0; i < (int)edges.size(); ++i) {
    int j = i + 1;
    while (j < (int)edges.size() &&
           edges[j].first.first == edges[i].first.first) {
      j++;
    }
    for (int k = i; k < j; k++) {
      int u, v;
      tie(u, v) = edges[k].second;
      if (get(u) != get(v)) {
        pos.push_back(edges[k].first.second);
      }
    }
    for (int k = i; k < j; k++) {
      int u, v;
      tie(u, v) = edges[k].second;
      if (get(u) != get(v)) {
        ans += edges[k].first.first;
        merge(u, v);
      }
    }
    i = j - 1;
  }
  sort(pos.begin(), pos.end());
  cout << ans << ' ' << pos.size() << endl;
  for (int k : pos) {
    cout << k << ' ';
  }
}
