#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const long long NINF = 0xdddddddddddddddd;
const int maxn = 2e5 + 11;
int N, M, T, P, Q;
int a[maxn];
list<int> G[maxn];
long long sum[maxn];
int sz[maxn], l[maxn], r[maxn], ver[maxn << 1];
int cur = 0;
void dfs(int u = 1, int pu = -1) {
  l[u] = ++cur;
  ver[cur] = u;
  sz[u] = 1;
  sum[u] = (long long)a[u];
  for (int v : G[u]) {
    if (v != pu) {
      dfs(v, u);
      sz[u] += sz[v];
      sum[u] += sum[v];
    }
  }
  r[u] = cur;
}
long long mmax[maxn << 2];
int inline LC(int i) { return i * 2; }
int inline RC(int i) { return i * 2 + 1; }
void build(int L, int R, int i) {
  if (L == R) {
    mmax[i] = sum[ver[L]];
    return;
  }
  int M = (L + R) / 2;
  build(L, M, LC(i));
  build(M + 1, R, RC(i));
  mmax[i] = max(mmax[LC(i)], mmax[RC(i)]);
}
int x1, x2;
long long res;
void query(int L, int R, int i) {
  if (x1 <= L && R <= x2) {
    res = max(res, mmax[i]);
    return;
  }
  int M = (L + R) / 2;
  if (x1 <= M) query(L, M, LC(i));
  if (x2 > M) query(M + 1, R, RC(i));
}
long long ans = NINF;
long long tmax[maxn], s1[maxn], s2[maxn];
void dfs2(int u = 1, int pu = -1) {
  x1 = l[u], x2 = r[u];
  res = NINF;
  query(1, cur, 1);
  tmax[u] = res;
  s1[u] = s2[u] = NINF;
  for (int v : G[u]) {
    if (v != pu) {
      dfs2(v, u);
      s2[u] = max(s2[u], tmax[v]);
      if (s2[u] > s1[u]) swap(s1[u], s2[u]);
    }
  }
  ans = max(ans, s1[u] + s2[u]);
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) scanf("%d", &a[i]);
  for (int i = 1; i < N; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  dfs();
  build(1, cur, 1);
  dfs2();
  if (ans <= (long long)(-1e12))
    puts("Impossible");
  else
    cout << ans << endl;
  return 0;
}
