#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 10;
const long long INF = 10e18;
vector<int> g[N];
long long scores[N];
bool vis[N];
long long dp[N];
long long sum[N];
int n;
long long ans;
void init() {
  for (int i = 1; i <= n; ++i) {
    g[i].clear();
  }
  memset(scores, 0, sizeof(scores));
  memset(vis, false, sizeof(vis));
  memset(dp, 0, sizeof(dp));
  memset(sum, 0, sizeof(sum));
  ans = -INF;
}
void dfs(int u) {
  sum[u] += scores[u];
  int len = g[u].size();
  for (int i = 0; i < len; ++i) {
    int v = g[u][i];
    if (vis[v]) continue;
    vis[v] = true;
    dfs(v);
    sum[u] += sum[v];
    if (dp[u] > -INF) ans = max(ans, dp[u] + dp[v]);
    dp[u] = max(dp[u], dp[v]);
  }
  dp[u] = max(dp[u], sum[u]);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  init();
  for (int i = 1; i <= n; ++i) {
    cin >> scores[i];
    dp[i] = -INF;
  }
  int u, v;
  for (int i = 1; i <= n - 1; ++i) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vis[1] = true;
  dfs(1);
  if (ans <= -INF)
    cout << "Impossible" << endl;
  else
    cout << ans << endl;
  return 0;
}
