#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10240000")
using namespace std;
const int MAXN = 200020;
const long long MAX_INF = (long long)1e16;
struct tedge {
  int t, next;
} e[MAXN * 2];
int cnt = 0;
long long ans = -MAX_INF;
long long w[MAXN], dp[MAXN], val[MAXN];
int st[MAXN];
bool flag = false;
void addedge(int x, int y) {
  cnt++;
  e[cnt].t = y;
  e[cnt].next = st[x];
  st[x] = cnt;
  cnt++;
  e[cnt].t = x;
  e[cnt].next = st[y];
  st[y] = cnt;
}
void dfs(int k, int pre) {
  val[k] = w[k];
  int numson = 0;
  long long maxv = -MAX_INF, maxv2 = -MAX_INF;
  for (int i = st[k]; i != -1; i = e[i].next) {
    int j = e[i].t;
    if (j != pre) {
      numson++;
      dfs(j, k);
      val[k] += val[j];
    }
  }
  dp[k] = val[k];
  for (int i = st[k]; i != -1; i = e[i].next) {
    int j = e[i].t;
    if (j != pre) {
      if (dp[j] > dp[k]) {
        dp[k] = dp[j];
      }
      if (dp[j] > maxv) {
        maxv2 = maxv;
        maxv = dp[j];
      } else if (dp[j] > maxv2) {
        maxv2 = dp[j];
      }
    }
  }
  if (numson >= 2) {
    flag = true;
    if (maxv + maxv2 > ans) {
      ans = maxv + maxv2;
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &w[i]);
    dp[i] = -MAX_INF;
  }
  memset(st, -1, sizeof(st));
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    addedge(x, y);
  }
  dfs(1, 0);
  if (flag) {
    printf("%I64d\n", ans);
  } else {
    printf("Impossible\n");
  }
  return 0;
}
