#include <bits/stdc++.h>
using namespace std;
long long p[200005];
vector<long long> v[200005];
struct node {
  long long sum;
  long long mx;
};
long long mxl[200005], smxl[200005];
node dfs(long long u, long long vis[], long long level) {
  vis[u] = 1;
  node cur;
  cur.sum = p[u];
  cur.mx = p[u];
  if (v[u].size() == 0) return cur;
  long long i;
  long long mx1 = -1e15;
  long long mx2 = -1e15;
  for (i = 0; i < v[u].size(); i++) {
    if (vis[v[u][i]] == 0) {
      node child = dfs(v[u][i], vis, level + 1);
      cur.sum += child.sum;
      if (child.mx > mx1) {
        mx2 = mx1;
        mx1 = child.mx;
      } else if (child.mx > mx2) {
        mx2 = child.mx;
      }
    }
  }
  if (mxl[level + 1] < mx1) {
    smxl[level + 1] = mxl[level + 1];
    mxl[level + 1] = mx1;
  }
  if (smxl[level + 1] < mx2) {
    smxl[level + 1] = mx2;
  }
  cur.mx = max(mx1, cur.sum);
  return cur;
}
int main() {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  long long i;
  for (i = 1; i <= n; i++) cin >> p[i];
  long long m = n - 1;
  while (m--) {
    long long a, b;
    ;
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  long long vis[n + 1];
  for (i = 1; i <= n; i++) {
    vis[i] = 0;
    mxl[i] = -1e15;
    smxl[i] = -1e15;
  }
  node q = dfs(1, vis, 0);
  long long ans = -1e15;
  for (i = 1; i < n; i++) {
    ans = max(ans, mxl[i] + smxl[i]);
  }
  if (ans > -1e15 / 2) {
    cout << ans;
  } else
    cout << "Impossible";
}
