#include <bits/stdc++.h>
using namespace std;
struct edge {
  int s, t, next;
} e[400010];
int head[200010], cnt;
void addedge(int s, int t) {
  e[cnt].s = s;
  e[cnt].t = t;
  e[cnt].next = head[s];
  head[s] = cnt++;
  e[cnt].s = t;
  e[cnt].t = s;
  e[cnt].next = head[t];
  head[t] = cnt++;
}
int n, u, v;
long long sum[200010], mx[200010];
int size[200010], val[200010];
long long ans = -1LL << 60, se;
void dfs(int node, int lastfa) {
  sum[node] = val[node];
  size[node] = 0;
  for (int i = head[node]; i != -1; i = e[i].next)
    if (e[i].t != lastfa) {
      dfs(e[i].t, node);
      sum[node] += sum[e[i].t];
      size[node]++;
    }
  mx[node] = -1LL << 60;
  se = -1LL << 60;
  for (int i = head[node]; i != -1; i = e[i].next)
    if (e[i].t != lastfa) {
      if (mx[e[i].t] > mx[node]) {
        se = mx[node];
        mx[node] = mx[e[i].t];
      } else if (mx[e[i].t] > se)
        se = mx[e[i].t];
    }
  if (size[node] > 1) ans = max(ans, mx[node] + se);
  mx[node] = max(mx[node], sum[node]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &val[i]);
  memset(head, 0xff, sizeof(head));
  cnt = 0;
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
  }
  dfs(1, 1);
  if (ans == -1LL << 60)
    printf("Impossible");
  else
    printf("%I64d", ans);
  return 0;
}
