#include <bits/stdc++.h>
using namespace std;
vector<long long> mx(2 * 100002);
vector<long long> siz(2 * 100002, 0);
vector<long long> a(2 * 100002);
vector<long long> total(2 * 100002);
vector<long long> v[2 * 100002];
long long n;
void dfs(long long v1, long long p) {
  siz[v1] = a[v1];
  mx[v1] = -LLONG_MAX;
  for (long long i = 0; i < v[v1].size(); i++) {
    long long to = v[v1][i];
    if (to == p) continue;
    dfs(to, v1);
    siz[v1] += siz[to];
    mx[v1] = max(mx[v1], mx[to]);
  }
  mx[v1] = max(mx[v1], siz[v1]);
}
void pfs(long long cur, long long pre) {
  long long max1 = -LLONG_MAX, max2 = -LLONG_MAX;
  for (long long j = 0; j < v[cur].size(); j++) {
    long long k = v[cur][j];
    if (k != pre) {
      if (mx[k] >= max1) {
        max2 = max1;
        max1 = mx[k];
      } else {
        if (mx[k] >= max2) max2 = mx[k];
      }
    }
  }
  if (max1 == -LLONG_MAX) total[cur] = -LLONG_MAX;
  if (max2 == -LLONG_MAX)
    total[cur] = -LLONG_MAX;
  else
    total[cur] = max1 + max2;
  for (long long j = 0; j < v[cur].size(); j++) {
    long long k = v[cur][j];
    if (k != pre) {
      pfs(k, cur);
    }
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n;
  long long ans = -LLONG_MAX;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (long long i = 1; i <= n - 1; i++) {
    long long c, d;
    cin >> c >> d;
    v[c].push_back(d);
    v[d].push_back(c);
  }
  if (n == 1) {
    cout << "Impossible";
    return 0;
  }
  long long cnt = 0, cnt2 = 0;
  for (long long i = 1; i <= n; i++) {
    if (v[i].size() == 1) cnt++;
    if (v[i].size() == 2) cnt2++;
  }
  if (cnt == 2 && cnt2 == n - 2 && v[1].size() == 1) {
    cout << "Impossible";
    return 0;
  }
  dfs(1, -1);
  pfs(1, -1);
  for (long long i = 1; i <= n; i++) {
    if (v[i].size() > 2) ans = max(ans, total[i]);
    if (i == 1 && v[i].size() <= 2) ans = max(ans, total[i]);
  }
  cout << ans;
}
