#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const long long INF = 1e18;
vector<int> g[MAXN];
long long a[MAXN], sum[MAXN], cnt[MAXN], dp[MAXN], ans;
void dfs(int v, int parent) {
  int to;
  sum[v] = a[v];
  for (int i = 0; i < g[v].size(); i++) {
    to = g[v][i];
    if (to == parent) continue;
    dfs(to, v);
    sum[v] += sum[to];
  }
}
void go(int v, int parent) {
  int to;
  pair<long long, long long> pr;
  dp[v] = sum[v];
  pr = make_pair(-INF, -INF);
  for (int i = 0; i < g[v].size(); i++) {
    to = g[v][i];
    if (to == parent) continue;
    go(to, v);
    dp[v] = max(dp[v], dp[to]);
    if (dp[to] >= pr.first) {
      pr.second = pr.first;
      pr.first = dp[to];
    } else if (dp[to] >= pr.second) {
      pr.second = dp[to];
    }
  }
  if (pr.second != -INF) ans = max(ans, pr.first + pr.second);
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, u, v;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  if (n == 1) {
    cout << "Impossible" << endl;
    return 0;
  }
  dfs(1, 0);
  ans = -INF;
  go(1, 0);
  if (ans == -INF)
    cout << "Impossible" << endl;
  else
    cout << ans << endl;
  return 0;
}
