#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> best[200010];
vector<int> arr[200010];
long long subtree[200010];
int val[200010];
int n;
long long maxans = -1e18;
void dfs(int s, int parent) {
  subtree[s] = val[s];
  long long maxx = -1e18, secmaxx = -1e18;
  for (int i = 0; i < arr[s].size(); ++i) {
    int to = arr[s][i];
    if (to != parent) {
      dfs(to, s);
      if (max(subtree[to], best[to].first) > maxx) {
        secmaxx = maxx;
        maxx = max(subtree[to], best[to].first);
      } else if (max(subtree[to], best[to].first) > secmaxx)
        secmaxx = max(subtree[to], best[to].first);
      subtree[s] += subtree[to];
    }
  }
  best[s].first = maxx;
  best[s].second = secmaxx;
  maxans = max(maxans, best[s].first + best[s].second);
}
void dfs2(int s, int parent) {}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &val[i]);
  int u, v;
  for (int i = 1; i < n; ++i) {
    scanf("%d", &u);
    scanf("%d", &v);
    arr[u].push_back(v);
    arr[v].push_back(u);
  }
  dfs(1, -1);
  if (maxans < -1e17)
    printf("Impossible\n");
  else
    printf("%lld\n", maxans);
  return 0;
}
