#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
const long long inf = 1e15;
long long dp[maxn], num[maxn], ans;
vector<int> G[maxn];
void dfs(int u, int fa) {
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) 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 n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%I64d", &num[i]);
    dp[i] = -inf;
    G[i].clear();
  }
  int u, v;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  ans = -inf;
  dfs(1, -1);
  if (ans == -inf)
    printf("Impossible\n");
  else
    printf("%I64d\n", ans);
  return 0;
}
