#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = (1LL << 60);
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int maxn = 5e5 + 10;
vector<int> g[maxn];
int a[maxn];
int n;
long long ans = -inf;
long long dp[maxn], f[maxn];
void dfs(int no, int p) {
  int sz = ((int)(g[no]).size());
  f[no] = a[no];
  dp[no] = -inf;
  for (int i = 0; i <= sz - 1; i++) {
    if (g[no][i] == p) continue;
    dfs(g[no][i], no);
    f[no] += f[g[no][i]];
    if (dp[no] > -inf) ans = max(ans, dp[no] + dp[g[no][i]]);
    dp[no] = max(dp[no], dp[g[no][i]]);
  }
  dp[no] = max(dp[no], f[no]);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1, 0);
  if (ans > -inf)
    printf("%lld\n", ans);
  else {
    puts("Impossible");
  }
  return 0;
}
