#include <bits/stdc++.h>
using namespace std;
struct line {
  int s, t;
  int next;
} a[400001];
int head[200001];
int edge;
inline void add(int s, int t) {
  a[edge].next = head[s];
  head[s] = edge;
  a[edge].s = s;
  a[edge].t = t;
}
int fa[200001];
long long sum[200001];
long long maxx[200001];
long long val[200001];
long long ans = -(1000000000LL * 1000000000LL);
inline void dfs(int d) {
  int i;
  long long max1 = -(1000000000LL * 1000000000LL),
            max2 = -(1000000000LL * 1000000000LL);
  maxx[d] = -(1000000000LL * 1000000000LL);
  for (i = head[d]; i != 0; i = a[i].next) {
    int t = a[i].t;
    if (t != fa[d]) {
      fa[t] = d;
      dfs(t);
      maxx[d] = max(maxx[d], maxx[t]);
      if (maxx[t] > max1) {
        max2 = max1;
        max1 = maxx[t];
      } else if (maxx[t] > max2)
        max2 = maxx[t];
      sum[d] += sum[t];
    }
  }
  sum[d] += val[d];
  maxx[d] = max(sum[d], maxx[d]);
  if (max1 != -(1000000000LL * 1000000000LL) &&
      max2 != -(1000000000LL * 1000000000LL))
    ans = max(ans, max1 + max2);
}
int main(void) {
  int n;
  scanf("%d", &n);
  int i;
  for (i = 1; i <= n; i++) scanf("%I64d", &val[i]);
  int s, t;
  for (i = 1; i <= n - 1; i++) {
    scanf("%d%d", &s, &t);
    edge++;
    add(s, t);
    edge++;
    add(t, s);
  }
  dfs(1);
  if (ans != -(1000000000LL * 1000000000LL))
    printf("%I64d\n", ans);
  else
    printf("Impossible\n");
  return 0;
}
