#include <bits/stdc++.h>
using namespace std;
const int N = 500000;
const long long minx = -0x5fffffffffffffff;
struct nn {
  long long x, y;
  nn() { y = minx; }
};
int n, u, v;
nn num[N];
vector<int> node[N];
long long dfs(int f, int x) {
  for (int i = 0; i < node[x].size(); i++) {
    if (node[x][i] == f) continue;
    long long r = dfs(x, node[x][i]);
    num[x].y += r;
  }
  return num[x].y;
}
long long dfs1(int f, int x, long long &ans) {
  long long m1 = minx;
  long long m2 = minx;
  for (int i = 0; i < node[x].size(); i++) {
    if (node[x][i] == f) continue;
    long long r = dfs1(x, node[x][i], ans);
    if (m1 < r) {
      m2 = m1;
      m1 = r;
    } else if (m2 < r) {
      m2 = r;
    }
  }
  if (m2 != minx) {
    if (ans < m1 + m2) ans = m1 + m2;
  }
  return m1 > num[x].y ? m1 : num[x].y;
}
int main() {
  long long ans;
  while (scanf("%d", &n) != EOF) {
    ans = minx;
    for (int i = 0; i < N; i++) node[i].clear();
    for (int i = 1; i <= n; i++) {
      scanf("%lld", &num[i].x);
      num[i].y = num[i].x;
    }
    for (int i = 0; i < n - 1; i++) {
      scanf("%d%d", &u, &v);
      node[u].push_back(v);
      node[v].push_back(u);
    }
    dfs(0, 1);
    dfs1(0, 1, ans);
    if (ans != minx)
      printf("%lld\n", ans);
    else
      printf("Impossible\n");
  }
  return 0;
}
