#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
const long long INF = 1e18;
long long a[N];
long long n;
vector<long long> g[N];
long long subtree[N], dp[N];
long long ans;
void dfs(long long node, long long par = -1) {
  subtree[node] = a[node];
  long long mx1 = -INF, mx2 = -INF;
  for (long long child : g[node]) {
    if (child == par) continue;
    dfs(child, node);
    subtree[node] += subtree[child];
    if (dp[child] >= mx1)
      mx2 = mx1, mx1 = dp[child];
    else if (dp[child] >= mx2)
      mx2 = dp[child];
  }
  if (mx2 != -INF) ans = max(ans, mx1 + mx2);
  dp[node] = max(subtree[node], mx1);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  ans = -INF;
  dfs(1);
  if (ans == -INF)
    cout << "Impossible";
  else
    cout << ans;
  return 0;
}
