#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "yes" : "no");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
const int MN = (1 << 20) + 5;
vector<int> mp[200135];
int a[200135], st[200135], ed[200135], cnt, rid[200135];
long long sa[200135];
void dfs(int x, int pa) {
  st[x] = ++cnt;
  rid[cnt] = x;
  sa[x] = a[x];
  for (int c : mp[x])
    if (c != pa) {
      dfs(c, x);
      sa[x] += sa[c];
    }
  ed[x] = cnt;
}
struct mb {
  int M;
  long long T[MN];
  void init(int sz) {
    for (M = 1; sz + 2 > M; M <<= 1)
      ;
    for (int(i) = 0; (i) < (int)(MN); (i)++) T[i] = -(1LL << 60);
    for (int(i) = 1; (i) <= (int)(sz); (i)++) T[M + i] = sa[rid[i]];
    for (int i = M - 1; i; i--) T[i] = max(T[i << 1], T[i << 1 | 1]);
  }
  void upt(int l, long long val) {
    l += M;
    T[l] = val;
    while (l > 1) {
      T[l >> 1] = max(T[l], T[l ^ 1]);
      l >>= 1;
    }
  }
  long long qy(int l, int r) {
    if (r < l) return -(1LL << 60);
    long long ans = -(1LL << 60);
    for (l = l + M - 1, r = r + M + 1; l ^ r ^ 1; l >>= 1, r >>= 1) {
      if (~l & 1) ans = max(ans, T[l ^ 1]);
      if (r & 1) ans = max(ans, T[r ^ 1]);
    }
    return ans;
  }
} T;
long long ans = -(1LL << 60);
void cal(int x, int pa) {
  long long gg = max(T.qy(1, st[x] - 1), T.qy(ed[x] + 1, n));
  if (gg != -(1LL << 60)) {
    ans = max(ans, gg + sa[x]);
  }
  T.upt(st[x], -(1LL << 60));
  for (int c : mp[x])
    if (c != pa) cal(c, x);
  T.upt(st[x], sa[x]);
}
void fmain() {
  scanf("%d", &n);
  for (int(i) = 1; (i) <= (int)(n); (i)++) scanf("%d", a + i);
  for (int i = 0, u, v; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    mp[u].push_back(v);
    mp[v].push_back(u);
  };
  dfs(1, 0);
  T.init(n);
  cal(1, 0);
  if (ans == -(1LL << 60))
    puts("Impossible");
  else
    printf("%lld\n", ans);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain();
  }
  return 0;
}
