#include <bits/stdc++.h>
using namespace std;
struct nevun {
  long long sumtot, maxun, doima, ta;
};
vector<int> g[200005];
long long val[200005], n;
nevun tati[200005];
void setarb(int nod) {
  long long maxnow = (0 - (1LL << 60));
  long long maxlo = (0 - (1LL << 60));
  tati[nod].sumtot = val[nod];
  tati[nod].maxun = (0 - (1LL << 60));
  tati[nod].doima = (0 - (1LL << 60));
  for (int i = 0; i < g[nod].size(); i++) {
    if (tati[g[nod][i]].ta == nod) {
      setarb(g[nod][i]);
      tati[nod].sumtot = tati[nod].sumtot + tati[g[nod][i]].sumtot;
      tati[nod].maxun = max(tati[nod].maxun, tati[g[nod][i]].maxun);
      tati[nod].doima = max(tati[nod].doima, tati[g[nod][i]].doima);
      if (tati[g[nod][i]].maxun >= maxnow) {
        maxlo = maxnow;
        maxnow = tati[g[nod][i]].maxun;
      } else {
        if (tati[g[nod][i]].maxun >= maxlo) {
          maxlo = tati[g[nod][i]].maxun;
        }
      }
    }
  }
  tati[nod].maxun = max(tati[nod].maxun, tati[nod].sumtot);
  int q = g[nod].size();
  long long x = tati[nod].doima;
  if (q > 2) {
    tati[nod].doima = maxlo + maxnow;
    tati[nod].doima = max(tati[nod].doima, x);
  } else {
    if (nod == 1) {
      if (q == 2) {
        tati[nod].doima = maxlo + maxnow;
        tati[nod].doima = max(tati[nod].doima, x);
      } else {
        tati[nod].doima = tati[g[nod][0]].doima;
      }
    } else {
      if (q == 2) {
        if (tati[nod].ta == g[nod][0]) {
          tati[nod].doima = tati[g[nod][1]].doima;
        } else {
          tati[nod].doima = tati[g[nod][0]].doima;
        }
      } else {
        tati[nod].doima = (0 - (1LL << 60));
      }
    }
  }
}
void dfs(int nod) {
  for (int i = 0; i < g[nod].size(); i++) {
    if (tati[g[nod][i]].ta == 0) {
      tati[g[nod][i]].ta = nod;
      dfs(g[nod][i]);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &val[i]);
  }
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (n > 1) {
    tati[1].ta = -1;
    dfs(1);
    setarb(1);
  }
  int gay;
  gay = 0;
  for (int i = 1; i <= n; i++) {
    int q = g[i].size();
    gay = max(gay, q);
  }
  if (n == 1 || (gay <= 2 && g[1].size() == 1)) {
    printf("Impossible");
  } else {
    printf("%I64d", tati[1].doima);
  }
  return 0;
}
