#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e6 + 30;
const int MAXN = 1e3 + 123;
const long long INF = 1e15;
const long long BINF = 1e18;
const int MOD = 1e9 + 7;
const long double EPS = 1e-15;
long long n;
long long a[MXN], cnt;
long long u[MXN];
long long sum[MXN], q;
vector<int> g[MXN];
long long tin[MXN], tout[MXN], ty;
long long mx = -BINF;
long long p[MXN];
multiset<long long> st[MXN];
multiset<long long>::iterator it, it2;
long long t[MXN * 4];
long long get_max(int x, int tl, int tr, int l, int r) {
  if (r < tl || tr < l) {
    return -INF;
  }
  if (l <= tl && tr <= r) {
    return t[x];
  }
  int mid = (tl + tr) / 2;
  return max(get_max(2 * x, tl, mid, l, r),
             get_max(2 * x + 1, mid + 1, tr, l, r));
}
void upd(int x, int tl, int tr, int ind, long long new_val) {
  if (tl == tr) {
    t[x] = new_val;
    return;
  }
  int mid = (tl + tr) / 2;
  if (ind <= mid) {
    upd(x + x, tl, mid, ind, new_val);
  } else {
    upd(x + x + 1, mid + 1, tr, ind, new_val);
  }
  t[x] = max(t[x + x], t[x + x + 1]);
}
void dfs(int v, int pr = 0) {
  tin[v] = ++ty, p[v] = pr;
  for (auto to : g[v]) {
    if (to != pr) {
      dfs(to, v);
      sum[v] += sum[to];
    }
  }
  if (g[v].size() > 2 || (v == 1 && g[v].size() > 1)) q = 1;
  sum[v] += a[v], tout[v] = ++ty, u[v] = ty;
}
void dfs2(int v, int pr = 0) {
  for (auto to : g[v]) {
    if (to != pr) {
      st[v].insert(get_max(1, 1, ty, tin[to], tout[to]));
      dfs2(to, v);
    }
  }
  if (st[v].size() > 1) {
    it = st[v].end(), it--;
    it2 = it, it2--;
    mx = max(mx, *it + *it2);
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1);
  if (!q) {
    cout << "Impossible" << '\n';
    return 0;
  }
  for (int i = 1; i <= n * 2; i++) {
    upd(1, 1, ty, i, -INF);
  }
  for (int i = 1; i <= n; i++) {
    upd(1, 1, ty, u[i], sum[i]);
  }
  dfs2(1);
  cout << mx;
  return 0;
}
