#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
struct node {
  int v, nxt;
} edge[200010 * 2];
long long dp[200010], sum[200010], w[200010], head[200010], tot, ans;
void add(int u, int v) {
  edge[tot].v = v;
  edge[tot].nxt = head[u];
  head[u] = tot++;
}
void dfs(int u, int fa) {
  sum[u] = w[u];
  for (int i = head[u]; ~i; i = edge[i].nxt) {
    int v = edge[i].v;
    if (v == fa) continue;
    dfs(v, u);
    sum[u] += sum[v];
    if (dp[u] > -INF) ans = max(ans, dp[u] + dp[v]);
    dp[u] = max(dp[u], dp[v]);
  }
  dp[u] = max(dp[u], sum[u]);
}
int main() {
  int n;
  cin >> n;
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n; i++) cin >> w[i];
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    add(u, v);
    add(v, u);
  }
  ans = -INF;
  for (int i = 1; i <= n; i++) dp[i] = -INF;
  dfs(1, -1);
  if (ans <= -INF)
    puts("Impossible");
  else
    cout << ans << endl;
  return 0;
}
