#include <bits/stdc++.h>
using namespace std;
long long n, val[200200];
long long siz[200020], maxi[200020];
vector<long long> graph[200300];
long long ans[200202];
void dfs(int start, int par) {
  multiset<long long> s;
  int sizz = graph[start].size();
  int i;
  siz[start] = val[start];
  long long damru = -99999999999999999LL;
  for (i = 0; i < sizz; i++) {
    int ele = graph[start][i];
    if (ele != par) {
      dfs(ele, start);
      siz[start] += siz[ele];
      damru = max(damru, maxi[ele]);
      s.insert(maxi[ele]);
      if (s.size() > 2) s.erase(s.begin());
    }
  }
  maxi[start] = max(maxi[start], max(damru, siz[start]));
  if (s.size() >= 2) {
    auto it = s.end();
    it--;
    long long temp1 = *it;
    it--;
    temp1 += *it;
    ans[start] = max(ans[start], temp1);
  }
  int siza = graph[start].size();
  for (int ii = 0; ii < siza; ii++) {
    int ele = graph[start][ii];
    if (ele != par) {
      ans[start] = max(ans[start], ans[ele]);
      maxi[start] = max(maxi[start], maxi[ele]);
    }
  }
}
int main() {
  int i, j, t;
  scanf("%lld", &n);
  ;
  for (i = 1; i <= n; i++) {
    ans[i] = maxi[i] = -99999999999999999LL;
    scanf("%lld", &val[i]);
    ;
  }
  for (i = 1; i < n; i++) {
    int st, en;
    scanf("%d%d", &st, &en);
    ;
    graph[st].push_back(en);
    graph[en].push_back(st);
  }
  dfs(1, 0);
  long long answ = -99999999999999999LL;
  for (i = 1; i <= n; i++) {
    answ = max(answ, ans[i]);
  }
  if (answ <= -99999999999999999LL)
    printf("Impossible\n");
  else
    cout << answ << endl;
  return 0;
}
