import sys sys.setrecursionlimit(10**7) 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]) dp = [[U[i]]*(M+1) for i in range(N)] import pypyjit pypyjit.set_param('max_unroll_recursion=-1') def dfs(x, par=-1): for nx, t in G[x]: if nx==par: continue dfs(nx, x) for m in range(M+1)[::-1]: for mm in range(M-m+1): T = m+mm+2*t if T