#include <bits/stdc++.h>
using namespace std;
long long dp[200010][3];
long long cst[200010];
long long sz[200010];
long long visited[200010];
vector<vector<int>> vt;
void dfs(long long here) {
  visited[here] = 1;
  sz[here] = cst[here];
  vector<long long> gap;
  for (int i = 0; i < vt[here].size(); i++) {
    int next = vt[here][i];
    if (!visited[next]) {
      dfs(next);
      sz[here] += sz[next];
      dp[here][2] = max(dp[here][2], dp[next][2]);
      dp[here][1] = max(dp[here][1], dp[next][1]);
      gap.push_back(dp[next][1]);
    }
  }
  dp[here][1] = max(dp[here][1], sz[here]);
  sort(gap.begin(), gap.end());
  if (gap.size() >= 2) {
    int t = gap.size();
    dp[here][2] = max(dp[here][2], gap[t - 1] + gap[t - 2]);
  }
}
int main() {
  for (int i = 1; i < 200010; i++) {
    dp[i][2] = -1e17;
    dp[i][1] = -1e17;
  }
  long long n;
  scanf("%lld", &n);
  vt.resize(n + 1);
  for (int i = 1; i <= n; i++) scanf("%lld", &cst[i]);
  for (int i = 1; i <= n - 1; i++) {
    long long q, w;
    scanf("%lld %lld", &q, &w);
    vt[q].push_back(w);
    vt[w].push_back(q);
  }
  dfs(1);
  if (dp[1][2] == -1e17)
    puts("Impossible");
  else
    printf("%lld", dp[1][2]);
}
