#include using namespace std; typedef long long ll; typedef pair P; int n,m; ll U[202]; vector

g[202]; ll dp[202][2002]; void dfs(int s, int prev) { for(int i = 0; i <= m; i++) dp[s][i] = U[s]; for(int i = 0; i < g[s].size(); i++) { int u = g[s][i].first; int c = g[s][i].second; if(u == prev) continue; dfs(u,s); for(int i = m; i >= 0; i--) { for(int j = 0; j + c <= i; j++) { dp[s][i] = max(dp[s][i],dp[s][i-(j+c)] + dp[u][j]); } } } } int main() { cin >> n >> m; m /= 2; for(int i = 0; i < n; i++) cin >> U[i]; for(int i = 0; i < n - 1; i++) { int a,b,c; cin >> a >> b >> c; g[a].push_back(P(b,c)); g[b].push_back(P(a,c)); } dfs(0,-1); ll ans = 0; for(int i = 0; i <= m; i++) ans = max(ans,dp[0][i]); cout << ans << endl; }