#include <bits/stdc++.h>
using namespace std;
multiset<long long> s[200005];
vector<long long> v[200005];
long long n, x, y, sum, sc[200005], a[200005], sol, i;
void df(int nod, int tata) {
  sc[nod] = a[nod];
  for (auto it : v[nod])
    if (it != tata) {
      df(it, nod);
      sc[nod] += sc[it];
      for (auto jt : s[it]) {
        s[nod].insert(jt);
        if (s[nod].size() > 2) s[nod].erase(s[nod].begin());
      }
    }
  if (s[nod].size() == 0) {
    s[nod].insert(sc[nod]);
    return;
  }
  if (s[nod].size() > 1) {
    sum = 0;
    for (auto jt : s[nod]) sum += jt;
    sol = max(sol, sum);
  }
  auto it = s[nod].begin();
  if (s[nod].size() > 1) it++;
  if (*it < sc[nod]) {
    s[nod].clear();
    s[nod].insert(sc[nod]);
  }
}
int main() {
  cin.sync_with_stdio(0);
  cout.sync_with_stdio(0);
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i < n; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  sol = -200000000000;
  df(1, 0);
  if (sol == -200000000000) {
    cout << "Impossible";
    return 0;
  }
  cout << sol;
  return 0;
}
