#include <bits/stdc++.h>
using namespace std;
int vis[200002];
long long a[200002], dp[200002], ans = -1e18;
;
vector<vector<int> > adj(200002);
long long dfs(int v) {
  if (vis[v] == 1) {
    return dp[v];
  }
  vis[v] = 1;
  long long s = 0;
  for (int i = 0; i < adj[v].size(); i++) {
    if (vis[adj[v][i]] == 0) {
      dp[adj[v][i]] = dfs(adj[v][i]);
      s += dp[adj[v][i]];
    }
  }
  return a[v] + s;
}
long long dfs2(int v) {
  if (vis[v] == 1) {
    return dp[v];
  }
  vis[v] = 1;
  vector<long long> x;
  for (int i = 0; i < adj[v].size(); i++) {
    if (vis[adj[v][i]] == 0) {
      x.push_back(dfs2(adj[v][i]));
    }
  }
  sort(x.begin(), x.end());
  reverse(x.begin(), x.end());
  if (x.size() >= 2) {
    ans = max(ans, x[0] + x[1]);
    return max(x[0], max(dp[v], x[1]));
  } else if (x.size() == 1) {
    return max(dp[v], x[0]);
  } else {
    return dp[v];
  }
}
int main() {
  long long n, i, u, v;
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dp[1] = dfs(1);
  memset(vis, 0, sizeof vis);
  dfs2(1);
  if (ans == -1e18)
    cout << "Impossible";
  else
    cout << ans;
}
