#include <bits/stdc++.h>
const int N = 2e5 + 10;
const int inf = 2 * 0x3f3f3f3f;
using namespace std;
long long num[N], dp[N], ans;
vector<int> vt[N];
void dfs(int u, int f) {
  int i;
  for (i = 0; i < vt[u].size(); i++) {
    int v = vt[u][i];
    if (v == f) continue;
    dfs(v, u);
    num[u] += num[v];
    if (dp[u] != -inf) ans = max(ans, dp[u] + dp[v]);
    dp[u] = max(dp[u], dp[v]);
  }
  dp[u] = max(dp[u], num[u]);
}
int main() {
  int i, n;
  long long a, b;
  while (scanf("%d", &n) != EOF) {
    ans = -inf;
    for (i = 1; i <= n; i++) {
      vt[i].clear();
      dp[i] = -inf;
    }
    for (i = 1; i <= n; i++) scanf("%lld", &num[i]);
    for (i = 1; i < n; i++) {
      scanf("%lld %lld", &a, &b);
      vt[a].push_back(b);
      vt[b].push_back(a);
    }
    dfs(1, -1);
    if (ans != -inf)
      printf("%lld\n", ans);
    else
      printf("Impossible\n");
  }
  return 0;
}
