#include <bits/stdc++.h>
using namespace std;
const long long minn = -100000000000000000LL;
long long a[200010];
vector<int> G[200010];
long long dp[200010][2];
long long sum[200020];
long long ans = 0;
void dfs(int u, int fa) {
  sum[u] = a[u];
  dp[u][0] = dp[u][1] = minn;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    if (v == fa) continue;
    dfs(v, u);
    sum[u] += sum[v];
    if (dp[v][0] >= dp[u][0]) {
      swap(dp[u][1], dp[u][0]);
      dp[u][0] = dp[v][0];
    } else if (dp[v][0] >= dp[u][1]) {
      dp[u][1] = dp[v][0];
    }
  }
  if (dp[u][1] != minn) ans = max(ans, dp[u][0] + dp[u][1]);
  dp[u][0] = max(sum[u], dp[u][0]);
}
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int u, v;
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  ans = minn;
  dfs(0, -1);
  if (ans == minn)
    cout << "Impossible" << endl;
  else
    cout << ans << endl;
  return 0;
}
