#include <bits/stdc++.h>
using namespace std;
int n;
int val[200005];
vector<int> adj[200005];
long long sum[200005];
long long max_sum[200005];
bool chain(int u, int p) {
  int cnt = 0;
  for (int v : adj[u]) {
    if (v == p) continue;
    if (++cnt > 1) return false;
    if (!chain(v, u)) return false;
  }
  return true;
}
long long calc_sum(int u, int p) {
  sum[u] = val[u];
  for (int v : adj[u]) {
    if (v == p) continue;
    sum[u] += calc_sum(v, u);
  }
  return sum[u];
}
long long calc_max(int u, int p) {
  max_sum[u] = sum[u];
  for (int v : adj[u]) {
    if (v == p) continue;
    max_sum[u] = max(max_sum[u], calc_max(v, u));
  }
  return max_sum[u];
}
long long find_ans(int u, int p) {
  long long ans = LLONG_MIN;
  int cnt = 0;
  vector<long long> children_ans;
  vector<long long> children_max;
  for (int v : adj[u]) {
    if (v == p) continue;
    cnt++;
    children_ans.push_back(find_ans(v, u));
    children_max.push_back(max_sum[v]);
  }
  if (cnt > 0) {
    ans = max(ans, *max_element(children_ans.begin(), children_ans.end()));
  }
  if (cnt > 1) {
    sort(children_max.begin(), children_max.end());
    ans = max(ans, children_max[cnt - 2] + children_max[cnt - 1]);
  }
  return ans;
}
int main() {
  scanf(" %d", &n);
  for (int i = 1; i <= n; i++) {
    scanf(" %d", &val[i]);
  }
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf(" %d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  if (chain(1, 1)) {
    printf("Impossible\n");
  } else {
    calc_sum(1, 1);
    calc_max(1, 1);
    printf("%lld\n", find_ans(1, 1));
  }
  return 0;
}
