#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = (long long)(2 * 1e15);
vector<vector<int>> graph;
vector<long long> a;
vector<long long> dp1, dp2;
long long ans = -INF;
void dfs(int u, int pr) {
  pair<long long, long long> now = make_pair(-INF, -INF);
  long long curr = -INF;
  dp1[u] = a[u];
  for (const int& v : graph[u])
    if (v != pr) {
      dfs(v, u);
      dp1[u] += dp1[v];
      dp2[u] = max(dp2[u], max(dp1[v], dp2[v]));
      curr = max(dp1[v], dp2[v]);
      if (curr > now.first) {
        now.second = now.first;
        now.first = curr;
      } else if (curr > now.second)
        now.second = curr;
    }
  if ((graph[u].size() - (pr != -1)) > 1)
    ans = max(now.first + now.second, ans);
}
int main() {
  std::ios::sync_with_stdio(false);
  int n, u, v;
  cin >> n;
  graph.resize(n);
  a.resize(n);
  dp1.resize(n);
  dp2.assign(n, -INF);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    --u;
    --v;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  dfs(0, -1);
  if (ans == -INF) {
    cout << "Impossible";
    return 0;
  }
  cout << ans;
  return 0;
}
