n, m = map(int, input().split()) u = [int(input()) for _ in range(n)] g = [[] for _ in range(n)] for _ in range(n-1): a, b, c = map(int, input().split()) g[a].append((b, c)) g[b].append((a, c)) t = [0]*(m+1) t[m] = u[0] def f(i, p): for j, c in g[i]: if j == p: continue for k in range(c*2, m+1): t[k-c*2] = max(t[k-c*2], t[k]+u[j]) f(j, i) f(0, 0) print(max(t))