#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
long long dp[200010], v[200010], sum[200010];
int head[200010], to[200010 * 2], pre[200010 * 2];
int n, e;
long long ans;
void addedge(int x, int y) {
  to[e] = y;
  pre[e] = head[x];
  head[x] = e++;
}
void dfs(int x, int pa) {
  sum[x] = v[x];
  for (int i = head[x]; i != -1; i = pre[i]) {
    if (to[i] == pa) continue;
    dfs(to[i], x);
    if (dp[x] != -inf) ans = max(ans, dp[x] + dp[to[i]]);
    sum[x] += sum[to[i]];
    dp[x] = max(dp[x], dp[to[i]]);
  }
  dp[x] = max(dp[x], sum[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%I64d", &v[i]);
  memset(head, -1, sizeof(head));
  e = 0;
  int x, y;
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &x, &y);
    addedge(x, y);
    addedge(y, x);
  }
  ans = -inf;
  for (int i = 1; i <= n; ++i) dp[i] = -inf;
  memset(sum, 0, sizeof(sum));
  dfs(1, 0);
  if (ans == -inf)
    printf("Impossible");
  else
    printf("%I64d\n", ans);
  return 0;
}
