#include <bits/stdc++.h>
int n;
long long ans = LLONG_MIN;
long long sum[(200010)], mxx[(200010)];
std::vector<int> mat[(200010)];
void dfs(int u, int fa) {
  long long nsum = 0, nmxx = LLONG_MIN;
  for (auto v : mat[u]) {
    if (v == fa) continue;
    dfs(v, u);
    if (nmxx != LLONG_MIN) {
      ans = std::max(ans, nmxx + mxx[v]);
    }
    nsum += sum[v];
    nmxx = std::max(nmxx, mxx[v]);
  }
  sum[u] += nsum;
  mxx[u] = std::max(sum[u], nmxx);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%I64d", sum + i);
  }
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    mat[u].push_back(v);
    mat[v].push_back(u);
  }
  dfs(1, 0);
  if (ans == LLONG_MIN) {
    printf("Impossible\n");
    return 0;
  }
  std::cout << ans << std::endl;
  return 0;
}
