#include <bits/stdc++.h>
using namespace std;
int a[200100];
long long val[200100];
long long mx[200100];
vector<int> adj[200100];
bool ok = 0;
long long ans = -1000000000000000ll;
void dfs(int u, int fa = 0) {
  val[u] += a[u];
  long long Mx1 = -1000000000000000ll, Mx2 = -1000000000000000ll, Mx;
  for (auto v : adj[u]) {
    if (v == fa) continue;
    dfs(v, u);
    val[u] += val[v];
    Mx2 = max(Mx2, mx[v]);
    if (Mx2 > Mx1) swap(Mx1, Mx2);
  }
  Mx = max(Mx1, Mx2);
  mx[u] = max(val[u], Mx);
  if (u != 1) {
    if (adj[u].size() >= 3) {
      ok = 1;
      ans = max(ans, Mx1 + Mx2);
    }
  } else if (adj[u].size() >= 2) {
    ok = 1;
    ans = max(ans, Mx1 + Mx2);
  }
}
int main() {
  int n;
  scanf("%d", &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);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) mx[i] = -1000000000000000ll;
  dfs(1);
  if (ok == 0)
    puts("Impossible");
  else
    printf("%I64d\n", ans);
  return 0;
}
