#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 5;
struct tree {
  int v, to;
} p[2 * maxn];
int t[maxn];
int tot;
long long a[maxn];
long long sons[maxn], dp[maxn];
long long ans;
void add(int v, int u) {
  p[tot].v = v;
  p[tot].to = t[u];
  t[u] = tot++;
}
void dfs(int fa, int v) {
  sons[v] = a[v];
  int cnt = 0;
  long long maxs = -1e15, sec = -1e15;
  for (int i = t[v]; i != -1; i = p[i].to) {
    int u = p[i].v;
    if (u == fa) continue;
    dfs(v, u);
    cnt++;
    sons[v] += sons[u];
    if (cnt == 1)
      maxs = dp[u];
    else {
      if (maxs < dp[u]) {
        sec = maxs;
        maxs = dp[u];
      } else if (sec < dp[u]) {
        sec = dp[u];
      }
    }
  }
  if (cnt > 1) ans = max(ans, maxs + sec);
  dp[v] = max(maxs, sons[v]);
}
int main() {
  int n;
  scanf("%d", &n);
  tot = 0;
  memset(t, -1, sizeof(t));
  for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  ans = -1e15;
  dfs(1, 1);
  if (ans == -1e15)
    puts("Impossible");
  else
    printf("%I64d\n", ans);
  return 0;
}
