func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2005, MOD = 1e9 + 7;   int d, n, a[N], dp[N], rt;   vector<int> g[N];   void dfs(int v, int pr = -1) {     dp[v] = 1;     for (int to : g[v]) {       if (to == pr) {         continue;       }       if (a[to] < a[rt] || a[to] > a[rt] + d) {         continue;       }       if (a[to] == a[rt] && to > rt) {         continue;       }       dfs(to, v);       dp[v] = (1ll * dp[v] * (dp[to] + 1)) % MOD;     }   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     cin >> d >> n;     for (int i = 1; i <= n; i++) {       cin >> a[i];     }     for (int i = 1; i < n; i++) {       int x, y;       cin >> x >> y;       g[x].push_back(y);       g[y].push_back(x);     }     int ans = 0;     for (int i = 1; i <= n; i++) {       rt = i;       dfs(rt, -1);       ans = (ans + dp[i]) % MOD;     }     cout << ans;   }   