#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const int N = 200;
struct edge {
  int v, nxt;
} e[N << 1];
int head[N], cnt, n, m, k, x, y, mp[N][N], f[N][N], pos[N], ans[N], d[N];
inline void add(int u, int v) {
  e[++cnt].v = v;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
inline void Floyd() {
  for (int i = 1; i <= n; ++i) mp[i][i] = 0;
  for (int k = 1; k <= n; ++k) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (i != j && j != k && k != i) {
          mp[i][j] = min(mp[i][j], mp[i][k] + mp[k][j]);
        }
      }
    }
  }
}
inline void dfs(int u, int fa) {
  for (int i = 1; i <= n; ++i) f[i][u] = d[mp[i][u]] + k;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(v, u);
    for (int j = 1; j <= n; ++j) f[j][u] += min(f[pos[v]][v], f[j][v] - k);
  }
  pos[u] = 1;
  for (int i = 1; i <= n; ++i)
    if (f[i][u] < f[pos[u]][u]) pos[u] = i;
}
inline void work(int u, int fa, int p) {
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    work(v, u, ans[v] = (f[pos[v]][v] > f[p][v] - k ? p : pos[v]));
  }
}
int main() {
  n = read();
  k = read();
  for (int i = 1; i < n; ++i) d[i] = read();
  memset(mp, 31, sizeof(mp));
  for (int i = 1; i < n; ++i) {
    x = read();
    y = read();
    add(x, y);
    add(y, x);
    mp[x][y] = mp[y][x] = 1;
  }
  Floyd();
  dfs(1, 0);
  printf("%d\n", f[pos[1]][1]);
  ans[1] = pos[1];
  work(1, 0, ans[1]);
  for (int i = 1; i <= n; ++i) printf("%d ", ans[i]);
  return 0;
}
