#include <bits/stdc++.h>
using namespace std;
int32_t main(void) {
  srand(time(0));
  cout << fixed << setprecision(7);
  cerr << fixed << setprecision(7);
  long long n;
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  static vector<long long> s[1 << 20];
  static long long v[1 << 20];
  static long long D[1 << 20];
  static long long S[1 << 20];
  for (long long i = 1; i <= n; ++i) cin >> v[i];
  for (long long i = 1; i < n; ++i) {
    long long a, b;
    cin >> a >> b;
    s[a].push_back(b);
    s[b].push_back(a);
  }
  long long ans = -1e18;
  function<void(long long, long long)> dfs = [&](long long node,
                                                 long long prev) {
    S[node] = v[node];
    pair<long long, long long> mx =
        make_pair((long long)(-1e18), (long long)(-1e18));
    for (auto it : s[node])
      if (it != prev) {
        dfs(it, node);
        S[node] += S[it];
        mx = max({mx, make_pair(mx.first, D[it]), make_pair(D[it], mx.first)});
      }
    if (min(mx.first, mx.second) > -1e18) ans = max(ans, mx.first + mx.second);
    D[node] = max(S[node], mx.first);
  };
  dfs(1, 0);
  if (ans > -1e18)
    cout << ans << '\n';
  else
    puts("Impossible");
  cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms"
       << '\n';
  return 0;
}
