#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
vector<int> edge[N];
int v[N], in[N];
long long sum[N], dp[N], res = -1e18;
int n;
void dfs(int x, int f) {
  sum[x] = v[x];
  long long fir = -1e18, sec = -1e18;
  for (int i = 0; i < edge[x].size(); i++) {
    int y = edge[x][i];
    if (y == f) continue;
    dfs(y, x);
    sum[x] += sum[y];
    dp[x] = max(dp[x], dp[y]);
    if (dp[y] > fir)
      sec = fir, fir = dp[y];
    else if (dp[y] > sec)
      sec = dp[y];
  }
  if (sec != -1e18) res = max(res, fir + sec);
  dp[x] = max(dp[x], sum[x]);
}
int main() {
  scanf("%d", &n);
  memset(dp, -127, sizeof(dp));
  for (int i = 1; i <= n; i++) scanf("%d", &v[i]);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    edge[u].push_back(v);
    in[u]++;
    edge[v].push_back(u);
    in[v]++;
  }
  long long fir = -1e18, sec = -1e18;
  dfs(1, 0);
  for (int i = 0; i < edge[1].size(); i++) {
    int y = edge[1][i];
    if (dp[y] > fir)
      sec = fir, fir = dp[y];
    else if (dp[y] > sec)
      sec = dp[y];
  }
  if (sec != -1e18) res = max(res, fir + sec);
  if (res == -1e18)
    puts("Impossible");
  else
    printf("%lld\n", res);
  return 0;
}
