#include <bits/stdc++.h>
using namespace std;
long long int dp[200005], ans[200005], sum[200005], a[200005];
vector<int> v[200005];
void solve(long long int x, long long int p) {
  int s, fi, si, i;
  s = v[x].size();
  sum[x] = a[x];
  ans[x] = -1000000000000000007;
  dp[x] = -1000000000000000007;
  fi = si = -1;
  for (i = 0; i < s; i++) {
    if (v[x][i] != p) {
      solve(v[x][i], x);
      ans[x] = max(ans[x], ans[v[x][i]]);
      dp[x] = max(dp[x], dp[v[x][i]]);
      sum[x] += sum[v[x][i]];
      if (fi == -1 || dp[v[x][i]] > dp[v[x][fi]]) fi = i;
    }
  }
  for (i = 0; i < s; i++) {
    if (v[x][i] != p) {
      if (i == fi) continue;
      if (si == -1 || dp[v[x][i]] > dp[v[x][si]]) si = i;
    }
  }
  dp[x] = max(dp[x], sum[x]);
  if (fi != -1 && si != -1) ans[x] = max(ans[x], dp[v[x][fi]] + dp[v[x][si]]);
}
int n, i, x, y;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n - 1; i++) {
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  solve(1, -1);
  if (ans[1] == -1000000000000000007)
    cout << "Impossible\n";
  else
    cout << ans[1] << "\n";
  return 0;
}
