#include <bits/stdc++.h>
using namespace std;
long long int ans = -(long long int)(1e17 + 1);
vector<long long int> adj[(long long int)(2e5 + 5)],
    p((long long int)(2e5 + 5)), dp((long long int)(2e5 + 5));
void dfs(long long int c, long long int pre) {
  dp[c] = p[c];
  for (auto x : adj[c]) {
    if (x == pre) continue;
    dfs(x, c);
    dp[c] += dp[x];
  }
}
void dfs1(long long int c, long long int pre) {
  long long int mx = -(long long int)(1e17 + 1),
                mx1 = -(long long int)(1e17 + 1);
  for (auto x : adj[c]) {
    if (x == pre) continue;
    dfs1(x, c);
    dp[c] = max(dp[c], dp[x]);
    if (dp[x] > mx) {
      mx1 = mx;
      mx = dp[x];
    } else
      mx1 = max(mx1, dp[x]);
  }
  ans = max(ans, mx + mx1);
}
void solve() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) cin >> p[i];
  for (long long int i = 1; i < n; i++) {
    long long int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0);
  dfs1(1, 0);
  if (ans >= -2e14)
    cout << ans;
  else
    cout << "Impossible";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) solve();
  return 0;
}
