#include <bits/stdc++.h>
using namespace std;
constexpr long long maxn = 2e5 + 5, inf = 1ll << 61;
long long n, m, k, a[maxn], f[maxn], res[maxn], mm, ans = -inf;
long long dp[maxn];
vector<long long> e[maxn];
void dfs(long long u, long long fa) {
  dp[u] = -inf;
  f[u] = a[u];
  for (auto v : e[u]) {
    if (v == fa) continue;
    dfs(v, u);
    f[u] += f[v];
    if (dp[u] > -inf) ans = max(ans, dp[u] + dp[v]);
    dp[u] = max(dp[u], dp[v]);
  }
  dp[u] = max(f[u], dp[u]);
}
signed main() {
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  dfs(1, 1);
  if (ans > -inf)
    cout << ans;
  else
    cout << "Impossible";
}
