#include <bits/stdc++.h>
using namespace std;
void In() { freopen("in.in", "r", stdin); }
void Out() { freopen("out.out", "w", stdout); }
const int N = 2e5 + 10;
const int M = 3e5 + 10;
const int Mbit = 1e6 + 10;
const long long inf = 1e15;
const long long mod = 1e9 + 7;
long long val[N], dp[N], ans;
vector<int> G[N];
void dfs(int u, int fa) {
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    dfs(v, u);
    val[u] += val[v];
    if (dp[u] != -inf) ans = max(ans, dp[u] + dp[v]);
    dp[u] = max(dp[u], dp[v]);
  }
  dp[u] = max(dp[u], val[u]);
}
int main() {
  int n;
  while (~scanf("%d", &n)) {
    for (int i = 1; i <= n; i++) scanf("%lld", &val[i]);
    for (int i = 1; i <= n; i++) G[i].clear(), dp[i] = -inf;
    ans = -inf;
    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(1, -1);
    if (ans != -inf)
      printf("%lld\n", ans);
    else
      puts("Impossible");
  }
  return 0;
}
