#include <bits/stdc++.h>
using namespace std;
int n, v, f[201][201], dis[201][201], a[201], b[201], c[201];
void dfs(int x, int fa) {
  int i, j;
  for (i = 1; i <= n; i++) f[x][i] = a[dis[x][i]] + v;
  for (i = 1; i <= n; i++)
    if (dis[x][i] == 1 && i != fa) {
      dfs(i, x);
      for (j = 1; j <= n; j++) f[x][j] += min(f[i][j] - v, f[i][b[i]]);
    }
  f[x][0] = 1e9;
  for (i = 1; i <= n; i++)
    if (f[x][i] < f[x][b[x]]) b[x] = i;
}
void getans(int x, int fa, int now) {
  int i;
  c[x] = now;
  for (i = 1; i <= n; i++)
    if (dis[x][i] == 1 && i != fa)
      getans(i, x, f[i][now] - v < f[i][b[i]] ? now : b[i]);
}
int main() {
  int i, ii, j, t, k;
  scanf("%d%d", &n, &v);
  memset(dis, 44, sizeof(dis));
  for (i = 1; i <= n; i++) dis[i][i] = 0;
  for (i = 1; i < n; i++) scanf("%d", &a[i]);
  for (i = 1; i < n; i++) {
    scanf("%d%d", &t, &k);
    dis[t][k] = dis[k][t] = 1;
  }
  for (ii = 1; ii <= n; ii++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        dis[i][j] = min(dis[i][j], dis[i][ii] + dis[ii][j]);
  dfs(1, 0);
  printf("%d\n", f[1][b[1]]);
  getans(1, 0, b[1]);
  for (i = 1; i <= n; i++) printf("%d ", c[i]);
}
