#include <bits/stdc++.h>
using namespace std;
const double eps = 0.0000001;
const long long inf = -1 * (1e17 + 7);
const int maxn = 200005;
long long dp[maxn], m1, m2, ans, f[maxn], num[maxn];
int flag, vis[maxn];
vector<int> son[maxn];
void dfs(int u, int fa) {
  f[u] = num[u];
  dp[u] = inf;
  long long tmp = inf;
  if (son[u].size() >= 3)
    flag = 1;
  else if (son[u].size() >= 2 && u == 1)
    flag = 1;
  for (auto v : son[u]) {
    if (fa == v) continue;
    dfs(v, u);
    ans = max(ans, tmp + dp[v]);
    f[u] += f[v];
    dp[u] = max(dp[u], dp[v]);
    tmp = max(tmp, dp[v]);
  }
  dp[u] = max(dp[u], f[u]);
}
int main() {
  int n;
  scanf("%d", &n);
  memset(dp, 0, sizeof(dp));
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; i++) scanf("%I64d", &num[i]);
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    son[x].push_back(y);
    son[y].push_back(x);
  }
  ans = inf;
  m1 = inf;
  dfs(1, -1);
  if (!flag)
    printf("Impossible\n");
  else
    printf("%I64d\n", ans);
}
