#include <bits/stdc++.h>
using namespace std;
long long int a[1000001];
long long int val[1000001];
vector<long long int> v[1000001];
long long int ans = -10000000000000000;
long long int f = 0;
long long int vis[1000001];
long long int d(long long int p) {
  long long int i, j, q;
  vis[p] = 1;
  val[p] += a[p];
  for (i = 0; i < v[p].size(); i++) {
    q = v[p][i];
    if (vis[q] == 1) continue;
    val[p] += d(q);
  }
  return val[p];
}
long long int dfs(long long int p) {
  long long int i, j, sum, k, q, t;
  sum = -10000000000000000;
  vis[p] = 1;
  vector<long long int> vv;
  for (i = 0; i < v[p].size(); i++) {
    q = v[p][i];
    if (vis[q] == 1) continue;
    t = dfs(q);
    vv.push_back(t);
  }
  sort(vv.begin(), vv.end());
  t = vv.size();
  if (t > 1) {
    ans = max(ans, vv[t - 1] + vv[t - 2]);
    f = 1;
  }
  if (t > 0) sum = max(sum, vv[t - 1]);
  sum = max(sum, val[p]);
  return sum;
}
int main() {
  long long int n, m, x, y, sum, t, i, j;
  cin >> n;
  for (i = 0; i < int(n); i++) cin >> a[i + 1];
  for (i = 0; i < int(n - 1); i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  d(1);
  for (i = 0; i < int(n + 1); i++) vis[i] = 0;
  dfs(1);
  if (f == 0)
    cout << "Impossible";
  else
    cout << ans;
}
