#include <bits/stdc++.h>
using namespace std;
void canhazfast() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <typename T>
T extgcd(T a, T b, T &x, T &y) {
  T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
  while (b) {
    T q = a / b;
    a %= b;
    swap(a, b);
    x0 -= q * x1;
    swap(x0, x1);
    y0 -= q * y1;
    swap(y0, y1);
  }
  x = x0;
  y = y0;
  return a;
}
int ctz(unsigned x) { return __builtin_ctz(x); }
int ctzll(unsigned long long x) { return __builtin_ctzll(x); }
int clz(unsigned x) { return __builtin_clz(x); }
int clzll(unsigned long long x) { return __builtin_clzll(x); }
int popcnt(unsigned x) { return __builtin_popcount(x); }
int popcntll(unsigned long long x) { return __builtin_popcountll(x); }
int bsr(unsigned x) { return 31 ^ clz(x); }
int bsrll(unsigned long long x) { return 63 ^ clzll(x); }
int nxt;
int id[200000], rnk[200000];
int l[200000], r[200000];
pair<int, int> e[200000];
vector<int> adj[200000];
void dfs(int u, int p = -1) {
  l[u] = nxt;
  for (int v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
  }
  nxt = max(nxt, l[u] + 1);
  r[u] = nxt;
}
int fin(int x) { return id[x] == x ? x : id[x] = fin(id[x]); }
bool uni(int x, int y) {
  x = fin(x);
  y = fin(y);
  if (x == y) return false;
  if (rnk[x] < rnk[y]) swap(x, y);
  id[y] = x;
  rnk[x] = max(rnk[x], rnk[y] + 1);
  return true;
}
int main() {
  canhazfast();
  int n;
  long long s = 0;
  vector<int> ans;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> e[i].first;
    e[i].second = i;
  }
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(0);
  iota(id, id + nxt + 1, 0);
  sort(e, e + n);
  for (int i = 0, j = 0; i < n;) {
    while (j < n && e[j].first == e[i].first) {
      int k = e[j].second, u = l[k], v = r[k];
      if (fin(u) != fin(v)) ans.push_back(k + 1);
      ++j;
    }
    while (i < j) {
      int k = e[i].second, u = l[k], v = r[k];
      if (uni(u, v)) s += e[i].first;
      ++i;
    }
  }
  sort((ans).begin(), (ans).end());
  cout << s << ' ' << ans.size() << '\n';
  for (int i : ans) cout << i << ' ';
  return 0;
}
