#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, a[maxn];
int head[maxn], cnt;
long long s[maxn], dp[maxn][2];
struct edge {
  int to, next;
} e[maxn << 1];
void adde(int u, int v) {
  e[++cnt].to = v;
  e[cnt].next = head[u];
  head[u] = cnt;
}
void dfs1(int u, int fa) {
  s[u] = a[u];
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs1(v, u);
    s[u] += s[v];
  }
}
void dfs2(int u, int fa) {
  dp[u][0] = max(dp[u][0], s[u]);
  long long mx1 = -1e18, mx2 = -1e18;
  for (int i = head[u]; i; i = e[i].next) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs2(v, u);
    dp[u][0] = max(dp[u][0], dp[v][0]);
    dp[u][1] = max(dp[v][1], dp[u][1]);
    if (mx1 <= -1e18 || dp[v][0] > mx1)
      mx2 = mx1, mx1 = dp[v][0];
    else if (mx2 <= -1e18 || dp[v][0] > mx2)
      mx2 = dp[v][0];
  }
  if (mx2 > -1e18) dp[u][1] = max(dp[u][1], mx1 + mx2);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), dp[i][0] = dp[i][1] = -1e18;
  for (int i = 1, u, v; i < n; i++)
    scanf("%d%d", &u, &v), adde(u, v), adde(v, u);
  dfs1(1, 0);
  dfs2(1, 0);
  if (dp[1][1] <= -1e18) return printf("Impossible\n"), 0;
  cout << dp[1][1];
  return 0;
}
