#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long INF = 1e17;
long long sum[N], mx[N], ans = -INF, a[N];
vector<int> g[N];
void dfs(int v, int par) {
  vector<long long> d;
  for (auto u : g[v])
    if (u != par) {
      dfs(u, v);
      sum[v] += sum[u];
      d.push_back(mx[u]);
      mx[v] = max(mx[v], mx[u]);
    }
  sum[v] += a[v];
  mx[v] = max(mx[v], sum[v]);
  sort(d.begin(), d.end(), greater<long long>());
  if (int(d.size()) < 2) return;
  ans = max(ans, d[0] + d[1]);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  fill(mx, mx + N, -INF);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n - 1; i++) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  dfs(0, -1);
  if (ans <= -INF)
    cout << "Impossible\n";
  else
    cout << ans << "\n";
  return 0;
}
