#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 200000;
const long long LINF = 1LL << 62;
int as[MAX_N], ps[MAX_N], cns[MAX_N];
vector<int> nbrs[MAX_N];
long long ss[MAX_N], dp0[MAX_N], dp1[MAX_N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--, v--;
    nbrs[u].push_back(v);
    nbrs[v].push_back(u);
  }
  ps[0] = -1;
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    int up = ps[u];
    vector<int> &nbru = nbrs[u];
    for (vector<int>::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
      int v = *vit;
      if (v != up) {
        ps[v] = u;
        cns[u]++;
        q.push(v);
      }
    }
  }
  fill(dp0, dp0 + n, -LINF);
  fill(dp1, dp1 + n, -LINF);
  long long maxsum = -LINF;
  for (int u = 0; u < n; u++)
    if (cns[u] == 0) q.push(u);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (dp1[u] > -LINF) {
      long long sum = dp0[u] + dp1[u];
      if (maxsum < sum) maxsum = sum;
    }
    ss[u] += as[u];
    int up = ps[u];
    if (up >= 0) {
      ss[up] += ss[u];
      long long d = max(ss[u], dp0[u]);
      if (dp0[up] < d)
        dp1[up] = dp0[up], dp0[up] = d;
      else if (dp1[up] < d)
        dp1[up] = d;
      if (--cns[up] == 0) q.push(up);
    }
  }
  if (maxsum <= -LINF)
    puts("Impossible");
  else
    printf("%lld\n", maxsum);
  return 0;
}
